KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > InitTest5


1 public class InitTest5 {
2
3     public class Inner1 {
4         public void m() {
5             System.out.println("hello from inner 1");
6         }
7     }
8
9     public static class Inner2 {
10         public void m() {
11             System.out.println("hello from inner 2");
12         }
13     }
14
15     public static interface InnerInterface1 {
16         public void go();
17     }
18     
19     public interface InnerInterface2 {
20         public void go();
21     }
22     
23     public static void main(String JavaDoc [] args){
24         InitTest5 it = new InitTest5();
25         it.run();
26         //Inner1 in = new Inner1();
27
class MyClass extends Inner2{
28             public void m() {
29                 System.out.println("hello from anon subtype of inner 1");
30             }
31         };
32         /*class MyClass1 extends MyStaticClass1{
33             public void m() {
34                 System.out.println("hello from anon subtype of inner 1");
35             }
36         };*/

37
38         new Inner2 () {
39             public void m(){
40                 System.out.println("hello from inner 2 again");
41             }
42         }.m();
43
44         new InnerInterface1 () {
45             public void go(){
46                 System.out.println("go");
47             }
48         }.go();
49
50         new InnerInterface2 () {
51             public void go(){
52                 System.out.println("go2");
53             }
54         }.go();
55
56         //int y = 9;
57
new MyObject1(){//y) {
58
public void go(){
59                 System.out.println("anon of non inner class");
60             }
61             
62         };
63     }
64
65     public void run(){
66         new Inner1 () {
67             public void m() {
68                 System.out.println("hello from anon subtype of inner 1");
69             }
70         }.m();
71         new Inner2 () {
72             public void m() {
73                 System.out.println("class to extend is inner static but not in static method");
74             }
75         }.m();
76     }
77 }
78
79 class MyObject1 {
80
81     public void go2(){
82         System.out.println("go2");
83     }
84 }
85
Popular Tags