Reputation: 8103
public class T146 { //LRU Cache
private HashMap<Integer, DoubleLinkedListNode> map
= new HashMap<Integer, DoubleLinkedListNode>();
private DoubleLinkedListNode head;
private DoubleLinkedListNode end;
private int capacity;
private int len;
public LRUCache(int capacity) {
this.capacity = capacity;
len = 0;
}
}
For this data structure.
if I initilized a instance of T146
.
Without setting t146.head = null.
can jvm guarantee t146.head
is null
?
THanks!
Upvotes: 0
Views: 49
Reputation: 310913
in java, is non-initialized object guarantee to be null?
Any non-initialized reference variable is guaranteed to be null if it's a class or instance member. Local variables have no default values at all, but the compiler will tell you if you try to use one before it's been initialized.
Upvotes: 1