
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i = 0; i < n; i++) {
for(int j = 0 ; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for(int i=1; i<=n; i++){
System.out.println("*".repeat(i));
}
}
}
System.out.println("*".repeat(i));
repeat(int count):String 클래스의 메서드로, 특정 문자열을 count만큼 반복하여 반환한다.System.out.println("A".repeat(5)); // "AAAAA" 출력
System.out.println("*".repeat(3)); // "***" 출력
i=1부터 n까지 증가하면서, "*".repeat(i)가 i번 반복된 문자열을 생성하고 출력.✅ Java 11 이상에서는 repeat()을 적극 활용하는 것이 효율적이다.
✅ 하지만 Java 8 이하에서는 repeat()가 없으므로 첫 번째 코드 방식 사용해야 한다.