问题
In Eclipse's Debugger I can change the value of a plain variable, but now I need to modify a List by removing or adding elements. Also, it can't be an empty list, it must contain specific items.
I right-click on the variable and try 'Change Value', but the following don't work:
new ArrayList<String>(Arrays.asList("333"));
==> ERROR: "Arrays cannot be resolved"
and
list.remove("12345");
list.remove("67890");
==> ERROR: Generated value (Boolean) is not compatible with declared type (java.util.List)
Any other ideas?
回答1:
If you need to enter complex expressions, it's probably easier to use the "Debug Shell" view. Using this, you can simple enter an expression or statement, highlight it, and execute it (or display it). You may have to replace references to classes (like "Arrays") with the fully-qualified class name. You can also enter and execute multiple statements, so if "Arrays.asList()" isn't convenient, just call "add()" multiple times.
来源:https://stackoverflow.com/questions/64430629/modifying-java-collection-list-variable-in-eclipse-debugger