Number Pattern 1 using Loop in Java

This tutorial entitles “Number Pattern 1 using Loop in Java” will teach you on how you can display a number pattern forming a triangle using for loop. Please follow all the steps to complete this tutorial.

Looping is a common feature use in any programming language especially in Java Program. This is a repetition statement with condition. If the condition is meet, the repetition or the looping stop.  There are three types of loop, the while loop, do while loop, and for loop.

Number Pattern 1 using Loop in Java Steps

  1. Create a new class and name it what you want to name.
How Print Hello World Text in Java, Sum Two Integers Values using Java
How Print Hello World Text in Java

2. Create a main method inside your class.

[java]public static void main(String args[]){

}[/java]

3. Insert the code below inside your main method for looping.

[java]for (int i = 1; i <=5;i++){
for (int j = 1;j <= i;j++){
System.out.print(j);
}
System.out.println();
}[/java]

Remember: 1 start the looping and 5 end the looping.

4. Run your program and the output should look like the image below.

5. Complete Source Code

[java]public class PatternNumber1 {
public static void main(String args[]){
for (int i = 1; i <=5;i++){
for (int j = 1;j <= i;j++){
System.out.print(j);
}
System.out.println();
}
}
}[/java]

About The Number Pattern 1 using Loop In Java

Project Name: Number Pattern 1 using Loop
Language/s Used: JAVA
Database: None
Type: Desktop Application
Developer: IT SOURCECODE
Updates: 0
Number Pattern 1 using Loop In Java– Project Information

Suggested Topic you may Like:

How to Check Highest Number in Java

Loop control In Java

Sum of Two Integers using Java

Leave a Comment