eparvan eparvan - 24 days ago 12
Java Question

How to initialize HashSet variable during debug in eclipse?

I'm trying to initialize

Set<String>
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

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"}));