...
| Code Block | ||
|---|---|---|
| ||
public Object pop() {
if (size==0)
throw new EmptyStackException(); // Ensures object consistency
Object result = elements[--size];
elements[size] = null; // Eliminate obsolete reference
size--;
return result;
}
|
| Wiki Markup |
|---|
While these examples may not model production scenarios, it is not uncommon to have _obsolete references_ when dealing with data structures such as hash tables that contain many large-sized records. It is prudent to assign {{null}} to array-like custom data structures, however, doing so with individual objects or local variables gives no specific advantage. The garbage collector is sufficiently equipped to handle these cases. \[[Commes 07|AA. Java References#Commes 07]\] |
...