null , . , , , - . null - , - , API , . Fail Fast
, API , , isEmpty(), .
, peek(), pop() add() - - isEmpty() API.
?
1 - null:
Integer x = stack.pop();
if (x != null) {
//do something with x
}
2 - :
Integer x = null;
try {
x = stack.pop();
} catch (MyException e) { }
//do something with x
- API.