Reference variable to an object instantiated/initialized in another class in Java

前端 未结 5 900
攒了一身酷
攒了一身酷 2021-01-25 05:41

The reason I\'m asking is because I\'m getting NullPointerException. I now this is very easy but I\'m pretty new programming and find this a bit confusing. So say I have initial

5条回答
  •  广开言路
    2021-01-25 05:58

    NPE is caused by an object not being instantiated. So resolving it requires instantiation. You do that with the new operator so new Board()

提交回复
热议问题