老师,请问为什么第二个for-each会报错呢?内部类对象不是Object对象吗?
public class listTest2 { public static void main(String[] args) { Set<String> a = new HashSet<>(); a.add("aaa");a.add("bbb");a.add("ccc"); for(Object temp:a){ System.out.println(temp); } Map<String,Integer> m = new HashMap<>(); m.put("C",1);m.put("A",1);m.put("B",1); Set<Map.Entry<String,Integer>> b = m.entrySet(); for(Object temp:b){ System.out.print(temp.getKey()+"-----"+temp.getValue()); } } }