首页 技术 正文
技术 2022年11月16日
0 收藏 467 点赞 2,809 浏览 1563 个字

手打的笔记:

() 内的则为注意事项或者提示

public static void main (String[] args) ******(用一个方法)****
{
int i = 10;

int j =20;

System.out.println(i == j);

与 并且关系:

System.out.println(true & true);

System.out.println(true & false);

System.out.println(false & true);

System.out.println(false & false);

System.out.println(i >0 && j>0);

或 或者关系:

System.out.println(true || true); (短路写法,只要前面对了,就都对了) (与并且相反)

非:

System.out.println(!(i < 0));

字节有八位

00000010

System.out.println(2 << 2); (00001000) 左移几位取决于后一位

3 2 = 12 3和2之间放什么符号 等式成立

左移运算规律:

x << y = x * 2的y次方

右移与左移相反

三元运算符:(不能单独存在,赋值或者输出)(可以套着写)

System.out.println(i>0 ? “i大于0” : “i小于等于0”); (类似if else 变形)

String str =””;

if(j>10)
{
str = “j大于10”;
}
else
{
str = “j不大于10”;
}

str = j >10 ? “j大于10″ :”j不大于10”;

System.out.println(str);

通过控制台手动输入:

System.in 输入流

System.out 输出流

Scanner sc =new Scanner(System.in); (实例化输入扫描器)

System.out.print(“请输入名称:”);

String strin = sc.nextLine(); (等待输入)

System.out.println(“你输入的名称是:”+ strin); (输出接受的)

加法计算器: (其他的计算类型随意)

System.out.print(“请输入第一个数字:”);

long a =sc.nextLong();

System.out.print(“请输入第二个数字:”);

long b =sc.nextLong();

System.out.println(a+b);

分支语句:

int i =10;

if(i>0)
{
System.out.println(“条件成立”)
}
else
{
System.out.println(“条件不成立”)
}

if(i>0)System.out.println(“i>0”); (简便写法)

if(i>0)
{
System.out.println(“条件成立”)
}
else if( i>5 )
{
System.out.println(“条件不成立”)
}

else

{

}

switch语句: (支持类型:int byte char short 枚举 字符串)

switch(i)

{

case1: (case后面必须为常量)

System.out.println(“1”);

break;

case2:

System.out.println(“4”);

break;

case3:

System.out.println(“6”);

break;

default:

System.out.println(“123”);
}

循环:

i=10;

while(i>0)
{
System.out.println(“i =”+i);

i–;
}

do

{
System.out.println(“i =”+i);

i–;

}

while(i>0);

for(i=0;i<10;i++)

{
System.out.println(“i =”+i);

if(i==2)
{
continue; (跳过 执行后面的)
}

if(i==5)
{
break;
}
}

}

手打的笔记,java语法中的输入输出,语句,及注释。

手打的笔记,java语法中的输入输出,语句,及注释。

手打的笔记,java语法中的输入输出,语句,及注释。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,083
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,558
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,407
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,180
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,817
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,900