Modifying Java Collection (List) Variable in Eclipse Debugger

时光总嘲笑我的痴心妄想 提交于 2021-01-29 11:00:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!