You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use [containsKey][map-containskey-javadoc] to see if the map contains a particular key.
38
38
39
39
```java
40
-
fruitPrices.containsKey("apple"); // => true
40
+
fruitPrices.containsKey("apple"); // => true
41
41
fruitPrices.containsKey("orange"); // => false
42
42
```
43
43
44
44
Remove entries with [remove][map-remove-javadoc].
45
45
46
46
```java
47
-
fruitPrices.put("plum", 90); // Add plum to map
48
-
fruitPrices.remove("plum"); // Removes plum from map
47
+
fruitPrices.put("plum", 90); // Add plum to map
48
+
fruitPrices.remove("plum"); // Removes plum from map
49
49
```
50
50
51
51
The [size][map-size-javadoc] method returns the number of entries.
@@ -54,10 +54,10 @@ The [size][map-size-javadoc] method returns the number of entries.
54
54
fruitPrices.size(); // Returns 2
55
55
```
56
56
57
-
You can use the [keys] or [values] methods to obtain the keys or the values in a Map as a Set or collection respectively.studentScores
57
+
You can use the [keySet][map-keyset-javadoc] or [values][map-values-javadoc] methods to obtain the keys or the values in a Map as a Set or collection respectively.studentScores
58
58
59
59
```java
60
-
fruitPrices.keys();// Returns "apple" and "pear" in a set
60
+
fruitPrices.keySet(); // Returns "apple" and "pear" in a set
61
61
fruitPrices.values(); // Returns 100 and 80, in a Collection
62
62
```
63
63
@@ -68,3 +68,5 @@ fruitPrices.values(); // Returns 100 and 80, in a Collection
0 commit comments