sobota, 10 września 2011

INNER CLASSES

1. Inner non-static class must not have static fields or methods.
2. Inner static class may have static fields and methods
3. It is illegal to add/hide static methods in anonymous inner class

eg.

class X {
      public static void do() {}
}

class Y{

public void method() {
    X x = new X() {
           public static void do() {}             //compile error
   };
}

Brak komentarzy:

Prześlij komentarz