Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize HashSet variable during debug in eclipse?

Tags:

java

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 ?

like image 253
eparvan Avatar asked Jul 25 '26 16:07

eparvan


1 Answers

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"}));
like image 196
janos Avatar answered Jul 28 '26 06:07

janos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!