I'm trying to add a char to an ArrayList of Chars from an array of chars for reasons I won't talk about for fear of making the post long. I am using this basic code:
for(char ch: c){
this.age.add(ch);
}
Where c is the array, and age is the ArrayList. Keep in mind that age is not initialized, therefore it is null. My question is, why am I getting a null pointer exception when I compile and run this?
this.ageis null ? Do you have elements inc?age = new ArrayList<>();