I need to change a variable while debugging an application. So far, these have been just basic variables that could be set directly. Now I need to clear the array so that isEmpty() returns true,
ArrayList<String> someList = new ArrayList<String>; someList.add("1"); ... if(someList.isEmpty()){
In the intellij debugger, I see:
someList={ ArrayList@4271 } size=1
I used the setValue method of the debugger and tried: new ArrayList<String>() or someList = new ArrayList<String>()
that leads to
someList={ ArrayList@4339 } size=0
However, if I continue, I get a NullPointerException when isEmpty () is called. So my question is: How can I introduce an empty ArrayList without getting NPE?
NPe text: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference
Lonzak
source share