1

I have MySubClass that extends MySuperClass. In MySuperClass I call the method MySubClass.getMap() from a static block in MySuperClass but it alway returns null. I really don't get why because in the same static block in MySuperClass I call MySubClass1.getMap(), MySubClass2.getMap(), MySubClass3.getMap() and so on; these are all subclasses of MySuperClass with that same identical format:

public class MySubClass extends MySuperClass {
    public MySubClass(int a, String b) {
        super(a, b);
    }

    public static HashMap<Integer, String> getMap() { return MAP; }
    protected static final HashMap<Integer, String> MAP = new HashMap<Integer, String>();
    static {
        MAP.putAll(MySubSubClass.ABILITIES);
    }
}

If I understand correctly from debugging (I'm relatively new to Java and Eclipse IDE), this static block up here doesn't get executed causing the null return value.

Korenji
  • 19
  • 4

0 Answers0