This question already has an answer here:
I have an ArrayList of Question Class objects and I need to output the random selected question in a JSF page. everithing seems OK but when I run it, gives me a java lang nullpointerException
public class GameBean implements Serializable {
private Random random;
private String question;
private String answer;
//above are the attributes
METHOD
public Question getQuestion() {
int index = random.nextInt(questionList.size());
Question q = questionList.get(index);
return q;}
JSF
<h:outputLabel value="#{GameBean.question}" />
Aucun commentaire:
Enregistrer un commentaire