运算符,包机制,javaDoc
-
二元运算符
package operator; public class Demo01 { public static void main(String[] args) { //二元运算符 //Ctrl + D:复制当前行到下一行 int a = 10; int b = 20; int c = 25; int d = 25; System.out.println(a+b); System.out.println(a-b); System.out.println(a*b); System.out.println(a/(double)b); } }
-
不同类型数据运算
package operator; public class Demo02 { public static void main(String[] args) { long a = 123123123123123L; 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 } }
-
关系运算符
package operator; public class Demo03 { public static void main(String[] args) { //关系运算符 int a = 10; int b = 20; int c = 21; System.out.println(c%b); //%取余 System.out.println(a<b); System.out.println(a>b); System.out.println(a==b); System.out.println(a!=b); } }
-
自增自减运算
package operator; public class Demo03 { public static void main(String[] args) { //关系运算符 int a = 10; int b = 20; int c = 21; System.out.println(c%b); //%取余 System.out.println(a<b); System.out.println(a>b); System.out.println(a==b); System.out.println(a!=b); } }
-
逻辑运算符
package operator; public class Demo05 { public static void main(String[] args) { //逻辑运算符:与(&&) 或(||) 非(!) boolean a = true; boolean b = false; System.out.println("a && b:"+(a && b)); //false System.out.println("a || b:"+(a || b)); //true System.out.println("! (a && b):"+!(a && b)); //true //短路预算 int c = 5; boolean d = (c<4) && (c++<4); //只进行到(c<4) System.out.println(d); System.out.println(c); } }
-
位运算
package operator; public class Demo06 { public static void main(String[] args) { /* //位运算 & | ~ ^ A = 0011 1100 B = 0000 1101 --------------------- A&B = 0000 1100 A|B = 0011 1101 A^B = 0011 0001 ~B = 1111 0010 2*8 = 16 2*2*2*2 效率极高!!! << 左移 *2 >> 右移 /2 0000 0000 0 0000 0001 1 0000 0010 2 0000 0011 3 0000 0100 4 0000 0101 5 0000 0110 6 0000 0111 7 0000 1000 8 0000 1001 9 0000 1010 10 0000 1011 11 0000 1100 12 0000 1101 13 0000 1110 14 0000 1111 15 0001 0000 16 */ System.out.println(2<<3); } }
-
字符串拼接
package operator; public class Demo07 { public static void main(String[] args) { int a = 10; int b = 20; a+=b; //a = a+b a-=b; //a = a-b System.out.println(a); //字符串拼接 + , String System.out.println(""+a+b); //1020 System.out.println(a+b+""); //30 } }
-
三元运算符
package operator; public class Demo08 { public static void main(String[] args) { //三元运算符 //x ? y :z //如果x==true,则结果为y,否则结果为z int score = 50; String type = score < 60 ? "不及格":"及格"; System.out.println(type); } }
-
包机制
-
生成javaDoc文档
-
cmd命令:javadoc -encoding UTF-8 -charset UTF-8 java文件
-
用IDEA产生javaDoc文档
package base; /** * @author Carl Zhou * @version 1.0 * @since 1.8 */ public class Doc { String name; /** * @author Carl Zhou * @param name * @return * @throws Exception */ public String test(String name) throws Exception{ return name; } //通过命令行 javadoc -encoding UTF-8 -charset UTF-8 java文件 //学会用IDEA生产javaDoc文档 }
-