public class Test_fun { public static void f1 (int x, int y){ System.out.println("f1"); }; public static int f2 (int x, int y){ //same signature as f1; has to have different name System.out.println("f2"); return x; }; public static void f3 (int x, int z){ //same signature as f1; has to have different name System.out.println("f3"); }; public static void f1 (int x){ // NUMBER of parameters is different from f1(int,int) System.out.println("f4"); }; public static void f1 (double x){ // TYPE of parameters is different from f1(int,int) and f1(int) System.out.println("f5"); simpl_loop(5); }; public static void simpl_loop(double max){ int i; System.out.println("simpl_loop max="+max); for (i=1; i<=max; i++){ System.out.println("\t i="+i); }; System.out.println("\t --- simpl_loop"); } public static int fp (int x){ System.out.println("\t\t inside fp - ini step"); return x; }; public static int fc (int x){ System.out.println("\t\t inside fc - comparison step - i="+i+"; x="+x); return x; }; public static void comp_loop(double max){ int i; System.out.println("comp_loop max="+max); for (i=fp(1); fc(i)<=max; System.out.println("\t\t iteration step: new i="+(++i))){ System.out.println("\t i="+i); }; System.out.println("\t --- comp_loop"); } public static double d; public static int i; public static void main(String args[]) { System.out.println("in Class Test_fun"); f1(1,1); f2(1,1); f1(1); f1(1.); i=3; System.out.println("i="+i); comp_loop(i); System.out.println("in main: i="+i); System.out.println("leaving Class Test_fun"); }; }; /* output: C:\Documents and Settings\Viktor Podolskiy>javac Test_fun.java C:\Documents and Settings\Viktor Podolskiy>java Test_fun in Class Test_fun f1 f2 f4 f5 simpl_loop max=5.0 i=1 i=2 i=3 i=4 i=5 --- simpl_loop i=3 comp_loop max=3.0 inside fp - ini step inside fc - comparison step - i=3; x=1 i=1 iteration step: new i=2 inside fc - comparison step - i=3; x=2 i=2 iteration step: new i=3 inside fc - comparison step - i=3; x=3 i=3 iteration step: new i=4 inside fc - comparison step - i=3; x=4 --- comp_loop in main: i=3 leaving Class Test_fun */