Doubt on pattern2

if i use this code

package javacrux;

import java.util.Scanner;

public class pattern0 {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n= scn.nextInt();
	
	 for(int row=1 ; row<=n ; row++) {
		 
		 for(int col=1 ; col<row ;col++) {
			 System.out.print("*");
		 }
		  
		 System.out.print("*");
		 System.out.print("\n");
		 
	 }

}

}

then its giving the same output
plz tell me that this is correct or incorrect

hey @harsh.hj ur code is fine . But A better way is to write your code this way
in Inner loop
for(int col=1 ; col<=row ;col++) {
System.out.print("* “);
}
System.out.print(”* ");// remove this line

ok sir :+1: thanks for helping

but it is for the first loop

Please mark your doubts as resolved in your course’s.

this is a first for loop
for(int row=1 ; row<=n ; row++) {

yes so for printing the star I have to write again syso("*")

yes so for printing the star I have to write again syso("*") in row

if Inner loop will look like this
for(int col=1 ; col<=row ;col++) {
System.out.print("");
}
don’t need this // yes so for printing the star I have to write again syso("
") in row