0

how to make this in array? * ** *** **** *****

22nd Aug 2016, 1:47 PM
bubbly
bubbly - avatar
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(); } } }
22nd Aug 2016, 5:30 PM
Tiger
Tiger - avatar
+ 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)); } } }
23rd Aug 2016, 11:08 AM
WPimpong
WPimpong - avatar
+ 2
why use array for this, its just longer lines of code..... the for loop is the best
23rd Aug 2016, 10:39 AM
dammy sammy
dammy sammy - avatar
0
thanksss 😃
23rd Aug 2016, 7:25 AM
bubbly
bubbly - avatar
0
give using for loop array example
17th Sep 2016, 4:38 PM
vijendiran
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(); }
7th Dec 2016, 3:11 PM
Sourav Kumar Singh
Sourav Kumar Singh - avatar