摘要:
// x ? y : z//如果x==true ,则结果为y,否则结果为yint score = 60;String type = score < 60 ? score + "分,不及格,继续努力" : "恭喜你"+score +"分,及格了";System.out.println(type); 阅读全文
posted @ 2021-11-18 13:08
在风雨中的她
阅读(18)
评论(0)
推荐(0)
摘要:
//扩展赋值运算符:+=,-=,*:*=,/=int a =10;int b =20;a+=b; //a = a+ba-=b; //a = a-bSystem.out.println(a);//字符串连接符 + ,只要有一个string类型的就都为string类型System.out.println 阅读全文
posted @ 2021-11-18 13:08
在风雨中的她
阅读(62)
评论(0)
推荐(0)
摘要:
// 与(and) 或(or) 非(取反)boolean a = true;boolean b = false;System.out.println("a && b:"+(a && b));//逻辑与运算:两个都为真,结果才为trueSystem.out.println("a || b:"+(a | 阅读全文
posted @ 2021-11-18 13:07
在风雨中的她
阅读(31)
评论(0)
推荐(0)
摘要:
// ++ -- 自增 自减 一元运算符int a = 3;int b = a++;//执行完这行代码后,先给b赋值,再自增// a++ a=a+1System.out.println(a);// ++a a=a+1int c = ++a;//执行完这行代码前,先自增,再给b赋值System.out 阅读全文
posted @ 2021-11-18 13:06
在风雨中的她
阅读(27)
评论(0)
推荐(0)
摘要:
//关系运算符返回的结果: 正确 错误 布尔值int a = 10;int b = 20;int c = 22;//取余System.out.println(c%b); // c/a 21/20 = 1.....2System.out.println(a>b);System.out.println( 阅读全文
posted @ 2021-11-18 13:05
在风雨中的她
阅读(33)
评论(0)
推荐(0)
摘要:
// 算术运算符:+, -, *, /, %, ++, -// 赋值运算符 =// 关系运算符:>, <, >=, <=, ==,!= instanceof// 逻辑运算符:&&,||, !// 位运算符: &,|,^,~,>>,<<, >>>(了解!!!)// 条件运算符 ? :// 扩展赋值运算 阅读全文
posted @ 2021-11-18 13:03
在风雨中的她
阅读(28)
评论(0)
推荐(0)
摘要:
//操作比较大的数的时候 //JDK7新特性,数字之间可以用下划线分割 int money = 10_0000_0000; int years = 20; int total1 = money * years;//-1474836480 计算的时候溢出了 long total2 = money * 阅读全文
posted @ 2021-11-18 13:01
在风雨中的她
阅读(22)
评论(0)
推荐(0)
摘要:
//属性:变量//实例变量:从属于对象; 如果不自行初始化,就是这个类型的默认值// 基本类型 0 0.0 u0000//布尔值:默认是false//除了基本类型,其余的默认值都是 nullString name;int age;//类变量 staticstatic double result = 阅读全文
posted @ 2021-11-18 13:01
在风雨中的她
阅读(34)
评论(0)
推荐(0)
摘要:
public class Demo04类型装换 { public static void main(String[] args) { //强制装换 (类型)变量名 从高 低 int i = 128; byte b = (byte) i; //内存溢出 System.out.println(i);// 阅读全文
posted @ 2021-11-18 12:59
在风雨中的她
阅读(32)
评论(0)
推荐(0)
摘要:
public class Demo03数据类型的扩展以及面试题 { public static void main(String[] args) { //整数拓展: 进制 二进制 0b开头 十进制 八进制 0开头 十六进制 0x开头 int i = 10; int i1 = 0b10; //二进制 阅读全文
posted @ 2021-11-18 12:58
在风雨中的她
阅读(29)
评论(0)
推荐(0)

浙公网安备 33010602011771号