I have this code that tells me a NullPointerException precisely at the method inizializza() at line:
valori[y].add(new Record(matriceBinaria[i][j], j));
How can I add items to the valori without that kind of exception?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You must also initialize each element in you array as follows :
ArrayList[size]is actually an array where each element is theArrayListobject. SinceArrayListis not a primitive you must alloacte memory for it by usingnew. So when you dovalori[y]in your code you are accessing an uninitialized (null) object