问题描述:

This question already has an answer here:

  • What is a NullPointerException, and how do I fix it?

    12 answers

网友答案:

I think you want if grille[i][j] == null instead of dereferencing joueur on it.

网友答案:

The problem with your code is that you have empty spots in your array. The loops are going to make blind calls, grille[0][0].joule then grille[0][1].joule then grille[0][2]. Since you didn't assign grille[0][2] it's null. Thus your null pointer exception.

相关阅读:
Top