public class EE { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(10/3); System.out.println((float)10/3); System.out.println( (float)(10/3) ); int x=2; switch(x){ case 1: System.out.println(1);break; case 2: System.out.println(2);break; case 3: System.out.println(3);break; } float y=2; switch(3){ //,不能是y, Cannot switch on a value of type float. Only convertible int values or enum constants are permitted //也就是说,只有当该数据类型可以自动转换为int型时,才可以作为switch的语句, //所以该类型表示的范围应该比int的小,short和byte都可以。 case 1: System.out.println(1);break; case 2: System.out.println(2);break; case 3: System.out.println(3);break; } } } public class FF { public static void main(String[] args) { // TODO Auto-generated method stub byte n=2; byte x=9; switch(n){ case 6/6: System.out.println(1);break; case 2: System.out.println(2);break; case 3: System.out.println(3);break; //case x: System.out.println(3);break;case expressions must be constant expressions } /* * int x =2; int y=3; 这里声明变量的方式" int a=0, b=0;" 如果写成" int a=0, int b=0;"是错误的, 因为如果声明为这种方式,则他们是两个语句, 要用分号隔开,但是for语句中分号真能有两个。所以使用"int a=0, b=0"这种方式 */ for(int a=0, b=0; a<2; b=++a, System.out.println("b="+b)){ System.out.println("a="+a); } } }