jeudi 14 octobre 2021

When I print a traingle pattern in java it print/show vertically? Help me solve it? [closed]

[[1]: https://i.stack.imgur.com/BOAxI.jpg]

java its * pattern problem and when I run this code in intellij idea the pattern print in vertical straight line , I don't know why its happening , someone help!

public class Main {

public static void main(String[] args) {
pattern1(4);
}
static void pattern1(int n) {
    for (int row = 1; row <= n ; row++) {
      
        for (int col = 1; col <= row ; col++) {
            System.out.println("*");
        }
        System.out.println();
                }
}

Aucun commentaire:

Enregistrer un commentaire