Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java hashmap key exists

@Test
public void whenKeyIsPresent_thenContainsKeyReturnsTrue() {
    Map<String, String> map = Collections.singletonMap("key", "value");
    
    assertTrue(map.containsKey("key"));
    assertFalse(map.containsKey("missing"));
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #java #hashmap #key #exists
ADD COMMENT
Topic
Name
8+3 =