eparvan eparvan - 1 year ago 126
Java Question

How to initialize HashSet variable during debug in eclipse?

I'm trying to initialize

variable during the debug session in eclipse. So I right-click on the variable to change and in "Change Object Value" window type the following expression:

new HashSet<String>(Arrays.asList(new String[]{"a", "b"}));

Eclipse returns the following error:

HashSet cannot be resolved to a type
Arrays cannot be resolved

Is there any way to initialize a collection during debug session in eclipse ?

Answer Source

If you want to use a class that is not imported (no corresponding import statement in the current file), then you can use these classes by their fully qualified names:

new java.util.HashSet<String>(java.util.Arrays.asList(new String[]{"a", "b"}));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download