Android - How to create a basic class and use it?
<p>I have defined a class that contains properties of a specific answer object
The class look like this and is defined inside the class that is trying to use it</p>

<pre><code>protected class Answer {
    String QuestionId = "";
    String AnswerValue = "";
    String Correct = "";
    public String getQuestionId() {
        return QuestionId;
    }
    public void setQuestionId(String arg) {
        QuestionId = arg;
    }
    public String getAnswerValue() {
        return AnswerValue;
    }
    public void setAnswerValue(String arg) {
        AnswerValue = arg;
    }
    public String getCorrect() {
        return Correct;
    }
    public void setCorrect(String arg) {
        Correct = arg;
    }
}
</code></pre>

<p>Not sure if the above is OK
When I try to use the class I get null pointer errors
I'm using it like this</p>

<pre><code>                ArrayList&lt;Answer&gt; answerList = new ArrayList&lt;Answer&gt;();
                for(int a=0;a&lt;answers.getLength(); a++){
                    Element eAnswer = (Element) answers.item(a);
                    Answer anAnswer = new Answer;
                    NodeList answer_nodes = eAnswer.getChildNodes();
                    for (int ian=0; ian&lt;answer_nodes.getLength(); ian++){
                        Node ans_attr = answer_nodes.item(ian);
                        String tag_name = ans_attr.getNodeName();
                        if(tag_name.equalsIgnoreCase("answer")){
                            anAnswer.setAnswerValue(ans_attr.getTextContent());
                        }
                    }
                    answerList.add(anAnswer);
                }
</code></pre>

<p>Answer anAnswer = new Answer; gives a compilation error
All I'm trying to do is to create a list of answers which have a name value pair for a number of properties</p>

<p>Any guidance on this greatly appreciated - Especially if there is a better way</p>
