What is a NullPointerException, and how do I fix it?
问题 This post is a Community Wiki . Edit existing answers to improve this post. It is not currently accepting new answers. What are Null Pointer Exceptions ( java.lang.NullPointerException ) and what causes them? What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely? 回答1: When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Consider the following code where you