What are the Java loops and array exercises
This article mainly introduces "what are Java loops and array exercises". In daily operation, I believe many people have doubts about Java loops and array exercises. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "what are Java loops and array exercises?" Next, please follow the editor to study!
Examples of loops:
While loop and do... While cycle
Whlie (conditional statement) {Loop body} / / first judge the conditional statement, and then proceed the loop body.
Do {Loop body} whlie (conditional statement) / / execute a loop first and then judge the conditional statement
Break statement
Break statement: ends all loops. The specific application is as follows:
1000) {break;// when the sum is greater than 1000, use the breakstatement to jump out of the loop}} System.out.println (I);}
Related example exercises:
1. Output 100 to 1000 daffodils:
Public class LoopTest {public static void main (String [] args) {int bai = 0; int shi = 0; int ge = 0; for (int I = 100; I < 1000; iAccording +) {bai = I bai 10; ge = I; if (bai*bai*bai+shi*shi*shi+ge*ge*ge = = I) {System.out.println (I);}}
two。 Print all letters:
Public class LoopTest {public static void main (String [] args) {char lower = 'a'; char upper =' Aids; for (int I = 0; I < 26; iTunes +) {System.out.println (lower+ "" + upper); lower++; upper++;}
3. Print the 99 multiplication table:
Public class LoopTest {public static void main (String [] args) {for (int I = 1; I)