Triangle Star Program Using Java

  1. import java.io.*;  
  2.   
  3. class triangle{  
  4.     public static void main(String[] args) {  
  5.         try{  
  6.             BufferedReader object = new BufferedReader(new InputStreamReader(System.in));  
  7.             System.out.println("enter the number");  
  8.             int a= Integer.parseInt(object.readLine());  
  9.             for (int i=1; i<a;i++ ){  
  10.                 for (int j=1; j<=i;j++ ){  
  11.                     System.out.print("*");  
  12.                 }  
  13.                 System.out.println("");  
  14.             }  
  15.         }  
  16.         catch(Exception e){}  
  17.     }