1、java支持如下的运算符
算数运算符:+,-,*,/,%(取余,也叫模运算),++,--
赋值运算符:==
关系运算符:>,<,>=,<=,==,!=,instceof
逻辑运算符:&&,||,!
位运算符:&,|,^,~,>>,<<,>>>(作为了解即可)
条件运算符: ?,:
扩展赋值运算符: +=,-=,*=,/=
2、可以这样new一个包package,在包里面新建类,会更简洁。

3、idea里面ctrl+d可以复制当前行到下一行,不需要选中,直接在分号后面按
4、
long a = 123456778;
int b = 123;
short c = 10;
byte d = 8;
System.out.println(a+b+c+d); ///long
System.out.println(b+c+d); //int
System.out.println(c+d); //int
//多个数中,有一个数类型为long,结果类型是long
//没long,无论有没有int,结果都是int
5、关系运算符的返回结果只有两个,正确或者错误,布尔值
二、自增自减运算符,初识Math类
int a = 3;
int b = a++; //a++ b=a a=a+1
int c = ++a; //++a c=a+1 a=a+1
System.out.println(a);
System.out.println(b);
System.out.println(c);
//幂运算 2^3 2*2*2 = 8
//很多运算会采用工具类进行操作
double pow = Math.pow(2, 3);
System.out.println(pow);
三、逻辑运算符,位运算符
1、逻辑运算符
//与(and) 或(or) 非(取反)
//与运算 一假则假,两真为真
//或运算 一真则真 两假为假
//非运算 真变假 假变真
boolean a = true;
boolean b = false;
System.out.println("a&&b:"+(a&&b)); //a&&b:false
System.out.println("a||b:"+(a||b)); //a||b:true
System.out.println("!(a&&b):"+(!(a&&b))); //!(a&&b):true
//短路运算
int c = 5;
boolean d = (c<4)&&(c++<4); //在判断出c<4是错误的后,d已经知道为false了,就不会再往后执行了
System.out.println(d); //false
System.out.println(c); //5
2、位运算
A = 0011 1100
B = 0000 1101
A&B = 0000 1100 //都是1才为1
A|B = 0011 1101 //都是0才为0
A^B = 0011 0001 //一样为0 不一样为1
~B(取反) 1111 0010
----------------------------------------------------------------------------
>> 右移 /2
<< 左移 *2
效率极高!!!
2*8=16 2*2*2*2
0000 0000 0
0000 0001 1
0000 0010 2
0000 0011 3
0000 0100 4
0000 1000 8
0001 0000 16 //观察不难发现是1左移1位*2
四、
1、
a+=b // a=a+b
//字符串连接符 + ,string
// 出现string也就是字符串类型后,他会把其余操作数也变成字符串类型,再进行连接
int a = 10;
int b = 20;
//细节:字符串在前就将后面的操作数转变为字符串类型再进行拼接
//字符串在后面前面的操作数还是会继续运算
System.out.println(""+a+b); //1020
System.out.println(a+b+""); //30
System.out.println(a+b+""+10); //3010
2、三元运算符
//x ? y : z
//if x==ture,则结果为y,否则结果为z
int score = 80;
String type = score < 60 ? "不合格" : "合格";
System.out.println(type); //合格
3、运算符的优先级

五、包机制
1、为更好地组织类,java提供了包机制,用于区别类名的命名空间
2、包的本质就是文件夹

创建空包的时候,输入com.baidu.www 会如图示

JavaDoc是一种将注释生成HTML文档的技术,生成的HTML文档类似于Java的API,易读且清晰明了。
文档注释
/**
*
*/

加在类上就是类的注释,加在方法上面就是方法的注释
idea生成javadoc文档:焯,没学明白,跳过了,等用到再回来学
浙公网安备 33010602011771号