What would be the return value of new in java in case of insufficient memory? I have the following code
TreeNode newNode = new TreeNode(n);
if(newNode == null)
return false;
eclipse says that it is a dead code. How should we check for memory error in java?
OutOfMemoryErrorwill be thrown.http://docs.oracle.com/javase/6/docs/api/java/lang/OutOfMemoryError.html