Map m = new HashMap();
Integer i = 5;
String s = null;
m.put("val1", i);
m.put("val2", s);
System.err.println(m.get("val1"));
System.err.println(String.valueOf(m.get("val1")));
System.err.println((String)m.get("val1")); //java.lang.Integer cannot be cast to java.lang.String
System.err.println(m.get("val2"));
System.err.println(String.valueOf(m.get("val2")));
System.err.println((String)m.get("val2"));
时间: 2024-11-10 08:11:52