KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Test13


1 interface MyListener {
2     public void action();
3 }
4
5 public class Test13 {
6
7     public static void main (String JavaDoc [] args){
8         Test13 t13 = new Test13();
9         MyListener ml = t13.run();
10         ml.action();
11         MyListener ml2 = t13.runAgain();
12         ml2.action();
13     }
14
15     public MyListener run(){
16         class MyListener1 implements MyListener {
17             public void action(){
18                 System.out.println("Smile");
19             }
20         };
21         return new MyListener1();
22     }
23     
24     public MyListener runAgain(){
25         class MyListener1 implements MyListener {
26             public void action(){
27                 System.out.println("Smile 2");
28             }
29         };
30         return new MyListener1();
31     }
32 }
33
Popular Tags