0
1 more question so how i can make this * ** ***
help
3 Respuestas
+ 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));
}
+ 2
More simple way in Java 8
for(int i = 1; i <=3; i++){
System.out.println(String.join("", Collections.nCopies(i, "*")));
}
+ 1
for (int i=0; i<4; i++){
for(int j=0; j<i; j++){
System.out.print("*");
}
System.out.print("\n");
}