/* leading inner 01234567890 row spaces spaces * * 0 0 9 * * 1 1 7 * * 2 2 5 * * 3 3 3 * * 4 4 1 * 5 5 0 */ public class ClassNameHere { public static void main(String[] args) { // 0123456789 String s = " "; for (int i = 0; i <= 4; ++i) { System.out.print( s.substring(0, i) ); System.out.print("*"); //System.out.print( s.substring(2*i) ); //System.out.print( s.substring(i, s.length()-i) ); System.out.print( s.substring(0, s.length()-2*i) ); System.out.println("*"); } System.out.println(" *"); } } /* 7 - row 7 - row row number number of row ROW spaces printed times 6 0 1 6 6 1 55 1 2 5 5 2 444 2 3 4 4 3 3333 3 4 3 3 4 22222 4 5 2 2 5 111111 5 6 1 1 6 0000000 6 7 0 0 7 */ public class ClassNameHere { public static void main(String[] args) { for (int row = 1; row <= 7; ++row) { for (int i = 1; i <= 7-row; ++i) { System.out.print(" "); } for (int i = 1; i <= row; ++i) { System.out.print(7 - row); } System.out.println(); } } } /* size 8 |/\|/\|/\|/\|/\|/\|/\|/\| */ public class ClassNameHere { public static void main(String[] args) { int size = 8; System.out.print("|"); // first post for (int i = 1; i <= size; i++) { System.out.print("/\\|"); // fence-post } System.out.println(); System.out.println(); for (int i = 1; i <= size; ++i) { System.out.print("|/\\"); // post-fence } System.out.println("|"); // last post } } /* size = 8 size - row row spaces ******************* * * * 1 7 * * * 2 6 * * * 3 5 * * * 4 4 * * * 5 3 * * * 6 2 * * * 7 1 * ** 8 0 ********** */ public class ClassNameHere { public static void main(String[] args) { for ( ) { System.out.print("*"); } System.out.println(); for (int row = 1; row <= size; ++row) { System.out.print("*"); for ( ) { System.out.print(" "); } System.out.print("*"); for ( ) { System.out.print(" "); } System.out.println("*"); } for ( ) { System.out.print("*"); } System.out.println(); } }