This article mainly describes the relevant information about Java applets in the for loop, which has some reference value. if you are interested, please refer to it.
1./** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates *//***@ author diyer6 ** TODO To change the template for this generated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * this figure shows the running result: **************************************** * **************/public class XingHaoOne {pub Lic static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int j = 0; j <10-i; j ++) {System. out. print ("") ;}for (int o = I; o> 0; o --) {System. out. print ("*");} System. out. print ("\ n ");}} 2./** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates *//***@ author diyer6 ** TODO To change the template for this gen Erated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * the figure is printed: **************************************** * **************/public class XingHaoTwo {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int n = I; n <11; n ++) {System. out. print ("*");} System. out. print ("\ n") ;}}3,/** Created on 2004-8-22 ** TODO To change the template for this generated file Go to * Window-Preferences-Java-Code Style-Code Templates * // *** @ author diyer6 *** TODO To change the template for this generated type comment go to * Window- preferences-Java-Code Style-Code Templates * // * This figure shows the running result: **************************************** * **************/public class XingHaoThree {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int j = 0; j System. out. pr Int ("*"); System. out. print ("\ n ");}}} 4./** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates *//***@ author diyer6 ** TODO To change the template for this generated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * this figure is printed: **************************************** ********* * *****/Public class XingHaoFour {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int j = I; j> 1; j --) {System. out. print ("") ;}for (int n = I; n <11; n ++) {System. out. print ("*");} System. out. print ("\ n ");}}} 5./** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates *//***@ author diyer6 ** TODO To cha Nge the template for this generated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * this figure shows the running result: **************************************** **************************************** * ****************************/public class XingHaoJuXing {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int n = 0; n System. out. print ("*") ;}for (int j = I; j <11; j ++) {System. ou T. print ("*");} System. out. print ("\ n ");}}} 6./** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates *//***@ author diyer6 ** TODO To change the template for this generated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * this figure is printed: **************************************** *********** **************************************** * ********/Public class Shishi {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int f = 0; f <10; f ++) {System. out. print ("*");} System. out. print ("\ n") ;}} another annotated one: /** Created on 2004-8-22 ** TODO To change the template for this generated file go to * Window-Preferences-Java-Code Style-Code Templates * // *** @ author diyer6 ** TODO To chan Ge the template for this generated type comment go to * Window-Preferences-Java-Code Style-Code Templates * // * this figure is printed: 0 ************************************** 0000 * * *** 000000 *** 0000000 *** 00000000 ***/public class Zaishi {public static void main (String [] args) {for (int I = 10; I> 0; I --) {for (int j = I; j <11; j ++) {// j = 10; j <11; print a 0 when repeating a loop. execute j ++, // j = 11 at this time; I <11; false, Therefore, only one 0 is printed in the first line. System. out. print ("0") ;}for (int n = I; n> 0; n --) {/* n = 10; n> 0; print *, execute n --, * at this time, n = 9; n> 0; recycle once, print another *, and execute n --, * at this time, n = 8; n> 0; loop once, print another *, execute n --, *, and so on... 10 x is printed in the first line *. * Next, run System. out. print ("\ n"); line feed. * Then execute I -- in the first large loop; then I is equal to 9. ** In this case, the first small loop is: (j = I starts from I = 9) * j = 9; j <11; loop twice, therefore, only two zeros are printed in the second row. * In the second small loop: (n = I starts from I = 9) * n = 9; n> 0; loop once, print a *, execute n --, * at this time, n = 8; n> 0; repeat once, print another *, execute n --, *, and so on... in the second row, nine * are printed *. * Next, run System. out. print ("\ n"); line feed. * Then execute I -- in the first large loop. at this time, I is equal to 8. ** And so on... */System. out. print ("*");} System. out. print ("\ n ");}}}
The above is a detailed description of the Java applet of the for loop. for more details, please follow other related articles in the first PHP community!