Java examples for Language Basics:for
how to generate pyramid or triangle like given below using for loop.
12345 1234 123 12 1
public class Main { public static void main(String[] args) { for(int i=5; i>0 ;i--){ /*from w w w . j a va2 s. co m*/ for(int j=0; j < i; j++){ System.out.print(j+1); } System.out.println(""); } } }