0% found this document useful (0 votes)
23 views1 page

For Loop Basics in Java

The document provides a Java code example demonstrating the use of a for loop to print numbers from 1 to 10. It includes the code snippet and the expected output. This exercise helps build a foundational understanding of loops in Java, which are essential for tasks involving repetition or iteration.

Uploaded by

Ramya Sajeeth
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

For Loop Basics in Java

The document provides a Java code example demonstrating the use of a for loop to print numbers from 1 to 10. It includes the code snippet and the expected output. This exercise helps build a foundational understanding of loops in Java, which are essential for tasks involving repetition or iteration.

Uploaded by

Ramya Sajeeth
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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.

You might also like