|
|
|
|
|
by hnthroaway1926
2649 days ago
|
|
Interesting, so they want to go beyond the line number of the exception and include information on what on the line is null. It's sort of funny that their example doesn't follow the usual Java style guidelines of encapsulating member variables in the parent and using set() and get() methods for access. a.to_b.to_c.to_d.num = 99; This could be rewritten as a method in 'A' as... protected void setDNum(int num) { C c = b.getC();
D d = c.getD();
d.setNum(99);
}In this case, a nullpointerexception would include the line number (using default compiler options) clearly indicating which is null. |
|