Patterns in the Java Program 2024

Best Patterns in Java Program 2024″ suggests a tutorial or resource showcasing some of the most effective and visually appealing patterns achievable through Java programming in the year 2024. Here’s a description of what such a resource might include:


class Mcqslist_com  {
         public static void main(String args[])  {
               int  row , col ;
               for (  row = 1 ; row <= 7 ; row++) { 
                      for( col = 7 ; col >= row ; col--)  { 
                            System.out.print(" ");
                      }
                      for( col = 1 ; col <= row ; col++) {
                            System.out.print( ( char )( 64 + col ) );
                      }
                      for( col = row - 1 ; col >= 1 ; col-- )  {
                             System.out.print( ( char )( 64 + col ) ) ;
                      }
                      System.out.print("\n");
                 }
         }
}
  • The outer loop (for (row = 1; row <= 7; row++)) iterates over each row from 1 to 7.
  • The first inner loop (for (col = 7; col >= row; col–)) prints spaces before printing the characters. The number of spaces decreases as the row number increases.
  • The second inner loop (for (col = 1; col <= row; col++)) prints characters from ‘A’ to the respective row number. The third inner loop (for (col = row – 1; col >= 1; col–)) prints characters from the respective row number – 1 down to ‘A’.
  • Finally, System.out.print(“\n”); moves to the next line after printing each row to create the triangular pattern.

Leave a Comment