【发布时间】:2016-11-14 20:08:30
【问题描述】:
我正在尝试在 Eclipse 的调试会话期间初始化 Set<String> 变量。所以我右键单击要更改的变量并在“更改对象值”窗口中键入以下表达式:
new HashSet<String>(Arrays.asList(new String[]{"a", "b"}));
Eclipse 返回以下错误:
HashSet cannot be resolved to a type
Arrays cannot be resolved
有什么方法可以在 Eclipse 中的调试会话期间初始化集合?
【问题讨论】:
-
请注意,您不需要显式创建数组:
Arrays.asList("a", "b")的工作方式相同。