私は宣言しました:
Discursiva[] questoesDiscursivas = new Discursiva[10];
これは:
public class Discursiva extends Questao{
private String criteriosCorrecao;
}
そしてQuestaoは:
public class Questao {
private String pergunta;
private double peso;
}
だから私はちょうどしました:
str = JOptionPane.showInputDialog("Pergunta da Questao:");
questoesObjetivas[i].setPergunta(str);
そして、java.lang.NullPointerExceptionを取得しました。
oracle docsを読みました:オブジェクトが必要な場合にアプリケーションがnullを使用しようとするとスローされます。これらには以下が含まれます:
Calling the instance method of a null object. Accessing or modifying the field of a null object. Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array. Throwing null as if it were a Throwable value.
そして、私はなぜ私が受け取っているのかわかりませんNullPointerException
。私の質問を裏付けないでください。IamはまだJavaを学習しています。これは、最初のコードのようです。助けてください。どうすればこれを修正できますか?