September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,15 +1,15 @@
|
|||
Map<String, Integer> myDict = new HashMap<>();
|
||||
myDict.put("hello", 1);
|
||||
myDict.put("world", 2);
|
||||
myDict.put("!", 3);
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
map.put("hello", 1);
|
||||
map.put("world", 2);
|
||||
map.put("!", 3);
|
||||
|
||||
// iterating over key-value pairs:
|
||||
myDict.forEach((k, v) -> {
|
||||
map.forEach((k, v) -> {
|
||||
System.out.printf("key = %s, value = %s%n", k, v);
|
||||
});
|
||||
|
||||
// iterating over keys:
|
||||
myDict.keySet().forEach(k -> System.out.printf("key = %s%n", k));
|
||||
map.keySet().forEach(k -> System.out.printf("key = %s%n", k));
|
||||
|
||||
// iterating over values:
|
||||
myDict.values().forEach(v -> System.out.printf("value = %s%n", v));
|
||||
map.values().forEach(v -> System.out.printf("value = %s%n", v));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue