java開発でMap.containsKeyの使い方
コード下記
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Mapkey {
public static void main(String[] args) {
Map map = new HashMap();
map.put(“eat", “apple");
map.put(“os", “linux");
map.put(“city", “tokyo");
map.put(“time", new Date());
String key = “city";
boolean contains = map.containsKey(key);
if (contains) {
System.out.println(“Map collection" + key+"value:"+map.get(key));
} else {
System.out.println(“Map not collect key" + key);
}
}
}