0

how to print? 1 22 333 need help..

need help

10th Aug 2016, 4:30 AM
Dinardoo Awangrief
Dinardoo Awangrief - avatar
3 ответов
+ 5
public class Program { public static void main(String[] args) { num(); System.out.println(); } public static void num() { for(int i=1; i<=3; i++) { for(int j=1; j<=i; j++) { System.out.print(i); } System.out.println(); } } }
10th Aug 2016, 4:48 AM
Mohammad Reza Karimi
Mohammad Reza Karimi - avatar
+ 3
Another simple way in Java 8. for(int i = 1; i <=3; i++){ System.out.println(String.join("", Collections.nCopies(i, String.valueOf(i)))); }
10th Aug 2016, 9:33 PM
WPimpong
WPimpong - avatar
0
oke thank you..
10th Aug 2016, 4:56 AM
Dinardoo Awangrief
Dinardoo Awangrief - avatar