Public classTest { Public Static voidMain (string[] args) {System.out.println ("Test is OK"); //T value entered by the customer intt = 100; //Statement if(T < 18) {System.out.println ("Very small."); } Else { if(T < 30) {System.out.println (Young people); } if(T > 90) System.out.println ("Too old."); } System.out.println (Welcome); //If there is no {}, only the next statement is affected, and if you need to influence multiple statements, you need to enclose it in {}. {} stands for scope intW = 2; String s= "10";//jdk1.7 Support for strings above version Switch(s) { Case"0": System.out.println ("Today is Sunday"); Break; Case"1": System.out.println ("Today is Monday"); Break;//If break is removed, execution continues down until a break is encountered//two different cases, the same result, can be removed break, penetrate to the next layer Case"2": System.out.println ("Today is Tuesday"); Break; Case"3": System.out.println ("Today is Wednesday"); Break; default: System.out.println ("Incorrect input"); Break; } //Loops inti = 10; while(I > 0) { if(i = = 8) {i--; Continue; } System.out.println ("*"); if(i = = 5) Break; } Do{System.out.println (i++); } while(I < 10);//"Do" loops at least once,System.out.println (); for(intm = 0;m < 10; M + +) { if(m = = 8)Continue; System.out.println ("M =" +m); } //TODO Auto-generated method stubs }}
Java Statement type