//----------------------------------------------------------------- // This is a program to print a sequence of '*' followed by // sequence of '+', followed by '-'. // This is (perhaps) less readable and more repetitive than the program // print_using_main_only.java which does not use any methods (except main) // To real appreciate the method based approach please compare the programs // realdiaomond.java and bad_diamond.java //----------------------------------------------------------------- class print_using_main_only { public static void main(String args[]) { int j=5; int k=0; for(k=1; k<=j;k=k+1) System.out.print('*'); for(k=1; k<=j+1;k=k+1) System.out.print('+'); for(k=1; k<=j+2;k=k+1) System.out.print('-'); System.out.println(""); } }