Ask your own question, for FREE!
Mathematics 17 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); } ```

OpenStudy (hyroko):

``` nameList.add(newElement); //here is where I'm getting the error. ```

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!