You are here: Home / Topics / Print star patter 1 logic in Java

Print star patter 1 logic in Java

Filed under: Java on 2023-08-18 06:38:27

// For loop pattern

public class NestedFor {

   public static void main(String[] args) {
       for (int i = 0; i < 5; i++) {
           for (int j = 0; j <= i; j++) {
               System.out.print("* ");
           }
           System.out.println();
       }
   }
}


Output:

*
* *
* * *
* * * *
* * * * *

About Author:
Y
Yatendra Sir     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.