A for statement is a repetitive syntax. If you can master the for statement, you will be able to handle large data with tables and many rows.
How to write
for (Initialization formula;Conditional expression;Renewal formula) {
Processing content;
}
Sample code:
ForSample.java
public class ForSample {
public static void main(String args[]) {
for(int x = 10; x < 20; x = x + 1) {
//Show x value
System.out.println("Value of x: " + x );
}
}
}
result
Value of x: 10
Value of x: 11
Value of x: 12
Value of x: 13
Value of x: 14
Value of x: 15
Value of x: 16
Value of x: 17
Value of x: 18
Value of x: 19
Recommended Posts