「java入門」containsKey(Object key)の使い方

javaコード
import java.util.HashMap;
import java.util.Map;
public class Weees {

public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put(“apple", “eat apple");
map.put(“computer", “mac pc");
map.put(“book", “spring mvc book");
String key = “book";
boolean contains = map.containsKey(key);
if (contains) {
System.out.println(“Map contain key:\n" + key);

} else {
System.out.println(“Map not contain key:\n" + key);

}

}

}

結果

Map contain key:
book

Java

Posted by arkgame