A
ankur
I was reading the code for HashMap.java from the source and did not
understand what is the object type of variable table in the default
constructor of HashMap object.
So in the class HashMap.java the follwoing appears:
transient Entry[] table;
public HashMap() {
this.loadFactor = DEFAULT_LOAD_FACTOR;
threshold = (int)(DEFAULT_INITIAL_CAPACITY *
DEFAULT_LOAD_FACTOR);
table = new Entry[DEFAULT_INITIAL_CAPACITY]; //What is the
object type here ???
init();
}
Since Entry is an Interface it does not have a constructor ...then how
is the table variable initialized in the deafault HashMap constructor
above ?
Thanks,
Ankur
understand what is the object type of variable table in the default
constructor of HashMap object.
So in the class HashMap.java the follwoing appears:
transient Entry[] table;
public HashMap() {
this.loadFactor = DEFAULT_LOAD_FACTOR;
threshold = (int)(DEFAULT_INITIAL_CAPACITY *
DEFAULT_LOAD_FACTOR);
table = new Entry[DEFAULT_INITIAL_CAPACITY]; //What is the
object type here ???
init();
}
Since Entry is an Interface it does not have a constructor ...then how
is the table variable initialized in the deafault HashMap constructor
above ?
Thanks,
Ankur