Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (hyroko):

For some reason.... I'm getting a null pointer exception..... while adding elements to an arraylist. I'm not even sure how that can happen...

OpenStudy (hyroko):

here's the code snippet ``` public void hash(Scanner scan){ ArrayList resList = null; ArrayList nameList = null; String[] stringsForArray = getArray(scan); for (String newElement : stringsForArray) { if(isReserved(newElement)){ resList.add(newElement); } else{ nameList.add(newElement); } } hashReserved(resList,scan); hashName(nameList, scan); } ``` Here's where the issue is ``` nameList.add(newElement);

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!