In this case, the stack trace would have the line with println on it at the top of the trace, because that is where the NullPointerException is thrown. The null reference is not a reference to an object, so there are no methods that can be invoked on it; in particular, the name.length() in the above example is what triggers the NullPointerException here.