AS中java.lang.NullPointerException: Attempt to invoke virtual method on a null object reference

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.skypan.travelsystem, PID: 23801
java.lang.NullPointerException: Attempt to invoke virtual method ‘void com.skypan.travelsystem.DataStructure.Point.setPoint_name(java.lang.String)’ on a null object reference
at com.skypan.travelsystem.DataStructure.ScenicSpot.(ScenicSpot.java:21)
at com.skypan.travelsystem.DataStructure.ScenicSpotArray.(ScenicSpotArray.java:42)
at com.skypan.travelsystem.activity.MainActivity$1.onClick(MainActivity.java:34)
at android.view.View.performClick(View.java:7448)
at android.view.View.performClickInternal(View.java:7425)
at android.view.View.access 3600 ( V i e w . j a v a : 810 ) a t a n d r o i d . v i e w . V i e w 3600(View.java:810) at android.view.View 3600(View.java:810)atandroid.view.ViewPerformClick.run(View.java:28305)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

在AndroidStudio开发中遇到诸如上述错误,绝大部分是没有创建方法Point.setPoint_name(java.lang.String)所属类的实例对象,在调用该方法之前new一个Point对象即可

你可能感兴趣的:(AndroidStudio开发,android,java,jdk)