Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
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 [] args){ 24 InitTest5 it = new InitTest5(); 25 it.run(); 26 class MyClass extends Inner2{ 28 public void m() { 29 System.out.println("hello from anon subtype of inner 1"); 30 } 31 }; 32 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 new MyObject1(){ 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
|