[Java Basics] Loop structure 1
Loop structure: For loop, while loop, Do_while loop, enhanced for loop
/**file path: G:\JavaByHands\ Loop statement file name: Whiletest.java written: 2016/6/7 Author: Zheng Write a description: While the Do while code example*/ Public classwhiletest{ Public Static voidMain (string[] args) {//Initial conditions inti = 0; //into the loop, while the loop first judges the re-operation condition while(I < 5) { //Output StatementSYSTEM.OUT.PRINTLN (i + "< 5")); //Operating conditionsi + +; } System.out.println (i); // Do While//Initialize Condition intj = 0; //go to loop do While loop first operation condition again Judge Do{System.out.println (J+ "<5"); J++; } while(J < 5); System.out.println (j); }}
/**file path: G:\JavaByHands\ Loop statement file name: Fortest.java Write Time: 2016/6/7 Author: Zheng Write a description: For loop code example*/ Public classfortest{ Public Static voidMain (string[] args) {//the most basic for loop for(inti = 0;i < 5; i + +) {System.out.println (i); } //Loop Nesting//First Floor for(intj = 0;j < 5; J + +) { //Second Floor for(intK = 0;k < 3; K + +) {System.out.println (The value of "J" is: "+j); System.out.println (The value of "K" is: "+k); System.out.println ("-------------"); } } }}
[Java Basics] Loop structure 1