Patterns: ========= class DiamondPattern{ public static void main(String[] args) { int rows = 6; int spaces = rows - 1; // upper triangle for(int r = 1;r <= rows;r++) { // for space printing for(int s = 1;s <= spaces;s++) { System.out.print(" "); } spaces--; for(int c = 1;c <= 2 * r - 1;c++) { System.out.print("*"); } System.out.println(); } spaces = 1; // lower triangle for(int r = 1;r <= rows-1;r++) { for(int s = 1;s <= spaces;s++) { System.out.print(" "); } spaces++; for(int c = 1;c <= 2*(rows-r) - 1;++c) { System.out.print("*"); } System.out.println(); } } } ============================================== class InvertedPyramidPattern{ public static void main(String args[]) { int rows = 7; // int space = 0; for(int i = 1;i <= rows;i++) { for(int s = 1;s <= i;s++) { System.out.print(" "); } // space++; for(int j = 1;j <= 2*(rows-i)-1;j++) { System.out.print("*"); } System.out.println(); } } } ============================================= class PascalTrianglePattern{ public static void main(String[] args) { int row = 5; for(int r = 1;r <= row;r++) { for(int c = 1;c <= r;c++) { System.out.print("* "); } System.out.println(); } for(int r = row-1;r >= 1;r--) { for(int c = 1;c <= r;c++) { System.out.print("* "); } System.out.println(); } } }