摘要: 1 /*测试for 2 * 用while和for循环输出1-1000之间能被5整除的数,且每行输出3个。 3 */ 4 public class TestFor { 5 public static void main(String[] args){ 6 for(int i = 1;i<=1000;i++){ 7 if(i%5==... 阅读全文
posted @ 2018-02-05 23:37 zbgghost 阅读(2748) 评论(0) 推荐(1) 编辑
摘要: 1 //jdk7.0中switch可以使用字符串做条件 2 public class TestSwitch02 { 3 public static void main(String[] args){ 4 String a = "向良峰"; 5 6 switch(a){//JDK 7的新特性,表达式可 阅读全文
posted @ 2018-02-05 23:09 zbgghost 阅读(453) 评论(0) 推荐(0) 编辑
摘要: 1 //反向利用case穿透 2 public class TestSwitch { 3 public static void main(String[] args){ 4 char c = 'a'; 5 int rand =(int) (26*Math.random()); 6 char c2 = 阅读全文
posted @ 2018-02-05 22:38 zbgghost 阅读(2493) 评论(0) 推荐(0) 编辑
摘要: 1 //测试if语句 2 public class TestIf { 3 public static void main(String[] args){ 4 double d = Math.random();//0~1之间的小数 5 int e = (int)(d*5); //[0,4] 6 //i 阅读全文
posted @ 2018-02-05 22:07 zbgghost 阅读(281) 评论(0) 推荐(0) 编辑