I have declared:
Discursiva[] questoesDiscursivas = new Discursiva[10];
Which is:
public class Discursiva extends Questao{
private String criteriosCorrecao;
}
And Questao is:
public class Questao {
private String pergunta;
private double peso;
}
So I just did:
str = JOptionPane.showInputDialog("Pergunta da Questao:");
questoesObjetivas[i].setPergunta(str);
And got java.lang.NullPointerException.
I have read in oracle docs: Thrown when an application attempts to use null in a case where an object is required. These include:
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.
And I dont get why I am receiving NullPointerException
.
Please dont bottomrate my question, Iam still learning Java, its like my first code in it and I would like your help, so please, how can I fix this?