Description:
Demonstrates how to use a for loop in Java to print numbers from 1 to 10.
Code:
java
CopyEdit
public class PrintNumbers {
public static void main(String[] args) {
// Print numbers from 1 to 10
for (int i = 1; i <= 10; i++) {
[Link](i);
}
}
}
Sample Output:
CopyEdit
1
2
3
4
5
6
7
8
9
10
Educational Use:
Builds foundational understanding of loops in Java — key for tasks that require repetition or
iteration.