Using Java I am trying to initialise member variables at declaring, but for some reason the variables stay at their default values e.g. 0, null etc.
Please see a snippet of example code which demonstrates what I'm trying to accomplish:
public class B extends A {
Map<Integer, Integer> map = new HashMap <Integer, Integer>();
int number = 10;
public B() {
super();
}
public Map getMap() {
return map;
}
public int getNumber() {
return number;
}
}
The important part of the code are that it is a subclass, and that I'm trying to initialise two member variables at declaration. When I step into the constructor the values of the map and number are null and 0 respectively, what is the reason for this?