i find with nullpointers it's normally best to check variables against null before you use them if(a != null) a.something(); else out.print("some error"); there are so many different nulls that can occur in one program i don't think a single page will be that helpful ?
Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
It's an ancient practice to return null to indicate some kind of failure or problem, probably dating back to the first days of C. This forces you to check for nulls. But there is a "null object" pattern that you can use. Instead of returning null, return a special instance or subclass of the expected object with the special behavior. Frinstance:
You could change getPage to return a NullPageObject which extends PageObject to always return "" and eliminate the test for null. Of course this mostly applies to where you are in control of introducing the null pointers in the first place. And it might be a strategy for handling some that are created by code that you cannot change. Here's an academic discussion ... I just Googled for "null object pattern" http://www.cs.oberlin.edu/~jwalker/nullObjPattern/
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
subject: Do you have elegant way of nullpointer exceptions