I get NPE when I try to convert my list back to an array. I debugged and found that my list gets an extra value that is null.
Why is this happening and more importantly, how can I fix this problem?
List<String> attrList = new LinkedList<String>(Arrays.asList(attrArray)) //I loop through and remove unnecessary elements attrArray = attrList.toArray(attrArray); //next line uses attrArray and is throwing NPE. Here what I found through debugging, attrList = [1, 2, 3] attrArray = [1, 2, 3, null]
source share