Official site: Java SE Bronze
: cherry_blossom: ** Java Bronze SE passed **: cherry_blossom:
1, while Use of statement 2, for Use of statements and extended for statements 3, do-while Creating and using statements 4, Loop nesting
Official site: The Java ™ Tutorials
while statement while (** condition **): As long as the condition is ** true **, it loops infinitely.
WhileDemo.java
class WhileDemo {
public static void main(String[] args) {
int count = -10;
while(count < 1) {
System.out.println("Count is : " + count);
count++;
}
}
}
for statement
ForDemo.java
class ForDemo {
public static void main(String[] args) {
for(int i = 0; i < 11; i++) {
System.out.println("Count is : " + i);
}
}
Extended for statement
EnhancedForDemo.java
class EnhancedForDemo {
public static void main(String[] args) {
int[] numbers = {1,2,3,4,5,6,7,8,9,10};
for(int item : numbers) {
System.out.println("Count is : " + item);
}
}
}
do-while statement Display once regardless of the condition.
DoWhileDemo.java
class DoWhileDemo {
public static void main(String[] args) {
int count = 1;
do {
System.out.println("Count is : " + count);
count++;
}while(count < 11);
}
}
Describe the for statement in the nesting for statement. The source code below represents the multiplication table.
Nesting.java
class NestingDemo {
public static void main(String[] args) {
for(int i = 1; i < 10; i++) {
for(int j = 1; j < 10; j++) {
System.out.print((i * j) + ",");
}
System.out.println("");
}
}
1, Data Declaration and Use 2, Loop statement
Recommended Posts