0

1 more question so how i can make this * ** ***

help

10th Aug 2016, 5:07 AM
Dinardoo Awangrief
Dinardoo Awangrief - avatar
3 Answers
+ 2
Another way with only one loop. int n = 3; char[] chars = new char[n]; Arrays.fill(chars, '*'); String allStar = new String(chars); while (n > 0){ System.out.println(allStar.substring(--n)); }
10th Aug 2016, 9:18 PM
WPimpong
WPimpong - avatar
+ 2
More simple way in Java 8 for(int i = 1; i <=3; i++){ System.out.println(String.join("", Collections.nCopies(i, "*"))); }
10th Aug 2016, 9:37 PM
WPimpong
WPimpong - avatar
+ 1
for (int i=0; i<4; i++){ for(int j=0; j<i; j++){ System.out.print("*"); } System.out.print("\n"); }
10th Aug 2016, 5:24 AM
Ahmed Shafeeu
Ahmed Shafeeu - avatar