0
how to make this in array? * ** *** **** *****
6 odpowiedzi
+ 7
public class Program
{
public static void main(String[] args) {
for(int i=0;i<5;i++){
for(int j=0;j<=i;j++)
System.out.print("*");
System.out.println();
}
}
}
+ 3
import java.util.Arrays;
public class Program
{
public static void main(String[] args) {
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
why use array for this, its just longer lines of code..... the for loop is the best
0
thanksss 😃
0
give using for loop array example
0
how about this???
char a[][]={{'*'},{'*','*'},{'*','*','*'},{'*','*','*','*'}};
for(int i=0;i<4;i++)
{
for(int j=0;j<i+1;j++)
System.out.print(a[i][j]);
System.out.println();
}