18 算数运算符
+ - * / % 整数的运算只能得到整数 除非用浮点数进行运算(得到浮点数)
public class Base_002 {public static void main(String[] args) {double a = 6.0;int b =4;System.out.println(a/b); //1.5}
}
19 字符的+操作
public class Base_002 {public static void main(String[] args) {int a =4;char b = 'A'; //65char c = 'a'; //97char d = '0'; //48System.out.println(a+b); //69System.out.println(a+c); //101System.out.println(a+d); // 52// char ch =a+c; //自定变为int类型int ch =a+c;System.out.println(ch); //101
// int k = 10+12.1; //报错double k = 10+12.1; //报错System.out.println(k); //22.1}
}
20 字符串的+操作
public class Base_002 {public static void main(String[] args) {System.out.println("it "+"heima");System.out.println("heima"+666);System.out.println(666+"heima");System.out.println("heima"+6+44);System.out.println(4+6+"heima");System.out.println("33"+"22"+"sss");
// it heima
// heima666
// 666heima
// heima644
// 10heima
// 3322sss}
}
21 赋值运算符
public class Base_002 {public static void main(String[] args) {short s =10;s +=10;System.out.println(s);
// s = s+10; //报错不兼容的类型s = (short) (s+10);System.out.println(s);}
}
22 自增自减运算符
public class Base_002 {public static void main(String[] args) {int i =10;int j = i++;System.out.println(i); //11System.out.println(j); //10}
}
23 关系运算符
24 逻辑运算符号
25 短路逻辑运算符
26 三元运算符
public class Base_002 {public static void main(String[] args) {int a = 10;int b = 20;int max = a > b ? a : b;System.out.println(max); //20}
}
27 两只老虎
略
(w1==w2)? true:flase
28 三个和尚
public class Base_002 {public static void main(String[] args) {int a = 10;int b = 20;int c = 15;int max = (a>b)? a:b ;int maxx = (max > c) ? max:c;System.out.println(maxx);}
}
29 数据输入
import java.util.Scanner;
public class Base_002 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int i = scanner.nextInt();System.out.println(i);}
}
30 三个和尚升级版本
略
31 顺序结构
略
32 if 语句
略
33 if else 语句
略
34 奇数偶数
略
35 if else if语句
36 考试奖励
略