1

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?

enter image description here

1
  • 2
    Actually, the following fully-qualified Arrays value worked: new ArrayList<String>(java.util.Arrays.asList("333","444")) Commented Oct 19, 2020 at 20:07

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, actually looks like even the Change Variable with a fully-qualified value will work, too: new ArrayList<String>(java.util.Arrays.asList("333","444"))
The advantage of using the "Debug Shell" view is that the expression you enter there doesn't go away after you execute it. It's not persistent over restarts, but if you have to execute that expression more than once in your session, it's much more convenient from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.