摘要: 从键盘分别输入年、月、日,判断这一天是当年的第几天 注:判断一年是否是闰年的标准: 1)可以被4整除,但不可被100整除 或 2)可以被400整除说明:1. 凡是可以使用switch-case的结构,都可以转换为if-else。反之,不成立。2. 我们写分支结构时,当发现既可以使用switch-ca 阅读全文
posted @ 2021-04-26 15:41 Hhhr 阅读(741) 评论(0) 推荐(0) 编辑
摘要: public class Demo { public static void main(String[] args){ //如何获取一个随机数:10 - 99 int value=(int)(Math.random()*90+10); System.out.println(value); } } p 阅读全文
posted @ 2021-04-26 15:04 Hhhr 阅读(100) 评论(0) 推荐(0) 编辑
摘要: public class Demo { public static void main(String[] args){ //获取三个数的最大值 int n1 = 12; int n2 = 30; int n3 = -43; int max1=(n1>n2)?n1:n2; int max2=(max1 阅读全文
posted @ 2021-04-26 14:24 Hhhr 阅读(831) 评论(0) 推荐(0) 编辑
摘要: class BitTest { public static void main(String[] args) { int m = 12; int n = 5; System.out.println("m & n :" + (m & n)); System.out.println("m | n :" 阅读全文
posted @ 2021-04-26 13:59 Hhhr 阅读(682) 评论(0) 推荐(0) 编辑
摘要: 结论:1. 位运算符操作的都是整型的数据2. << :在一定范围内,每向左移1位,相当于 * 2 >> :在一定范围内,每向右移1位,相当于 / 2 面试题:最高效方式的计算2 * 8 ? 2 << 3 或 8 << 1 2<<3 每向左移3位,相当于2*2*2*2=16 8<<1 每向左移3位,相 阅读全文
posted @ 2021-04-26 11:23 Hhhr 阅读(107) 评论(0) 推荐(0) 编辑
摘要: class Test1 { public static void main(String[] args){ int num=129; int bai=num/100; int shi=num%100/10;//129%100=29 29/10=2 int ge=num%10; System.out. 阅读全文
posted @ 2021-04-26 11:03 Hhhr 阅读(372) 评论(0) 推荐(0) 编辑