function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yuvraj.chaudhari88@gmail.comyuvraj.chaudhari88@gmail.com 

write a code for printing the reverse triangle

PrasanntaPrasannta (Salesforce Developers) 
Please refer to below code to print triangle in java.
Try to execute it in eclipse(Force.com IDE)

import java.util.Scanner;
class RevTriangle{
  public static void main(String agrs[]){
    Scanner k = new Scanner (System.in);
    int line = k.nextInt();
    int x = (line * 2) - 1;
    int y = 1 ;

    for(int l = 0; l < line; l++){
     
      for(int s = y; s > 0; s--){
        System.out.print(" ");
      }
     
      for(int s = 0; s < x ; s++){
        System.out.print("*");
      }
     
      System.out.println();
      x-=2;
      y++;
    }
  }
}

Hope it helps.