62,623
社区成员
发帖
与我相关
我的任务
分享
Map<String, Object> map = new HashMap<String, Object>();
private static void map () {
Map map = new HashMap();
map.put("str", ""); // 放String
map.put("int", 1); // 放int
map.put("long", new Long(123456)); // 放Long
String str = (String) map.get("str");// 取String
int i = (Integer) map.get("int");// 取int
Long l = (Long) map.get("long");// 取Long
}
Iterator iterator = collection.iterator()
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof Collection)
messyPrintCollection((Collection)o);
else if (o instanceof String)
System.out.println("'"+o.toString()+"'");
else if (o instanceof Float)
System.out.println(o.toString()+"f");
else
System.out.println(o.toString());
}