摘要:1 public class TestBreakAndContinue { 2 3 /** 4 * 测试break and continue 5 */ 6 public static void main(String[] args) { 7 int total =0; 8 System.out.println(...
阅读全文
摘要:1 public class TestWhileAndFor2 { 2 3 /** 4 * 九九乘法表 5 * 1!+2!+3!+....+10!=? 6 * 7 */ 8 public static void main(String[] args) { 9 /* 10 for(int...
阅读全文
摘要:1 public class TestWhileAndFor { 2 3 /**测试 while和for循环练习 4 * 100 以内的奇数和偶数的和 5 * @author Administrator 6 * 7 */ 8 public static void main(String[] args) { 9 ...
阅读全文
摘要:1 /** 2 * JDK7.0新特性 7.0以前 表达式的结果只能是int(或者可以自动转成int的 byte short char)枚举类型 3 * 7.0之后 表达式可以是 字符串! 4 * 如果想看效果 就装上7以上的版本 5 */ 6 public class TestSwitch { 7 public static void main(Stri...
阅读全文
摘要:1 // 测试if 2 public class TestIf { 3 public static void main(String[]args){ 4 //[0,1)的随机小数 5 double d =Math.random(); 6 int e= 1+(int)(d*6); 7 System.out.pri...
阅读全文
摘要:1 public class TestFor { 2 3 /** 4 * 测试for循环; 5 * 加强版for循环 foreach 6 */ 7 public static void main(String[] args) { 8 for(int a=0;a<=100;a++){ 9 ...
阅读全文
摘要:1 public class TestDoWhile { 2 3 /**do while 至少执行一次 先斩后奏 4 * 测试dowhile 5 */ 6 public static void main(String[] args) { 7 int a=0; 8 while(a<0){ 9 ...
阅读全文
摘要:1 public class TestWhile { 2 3 /** 4 * 测试循环 5 */ 6 public static void main(String[] args) { 7 int a=1; 8 while(a<=100){ 9 System.out.println(a)...
阅读全文