ImmutableMap.java
package com.java9r;
import java.util.*;
public class ImmutableMap {
public static void main(String[] args) {
try {
System.out.println("Prodicts List");
Map<Integer, String> prosdict = Map.ofEntries(Map.entry(1, "Prodict 1"),
Map.entry(2, "Prodict 2"), Map.entry(3, "Prodict 3"),
Map.entry(4, "Prodict 4"),
Map.entry(5, "Prodict 5"));
prosdict.forEach((key, value) -> {
System.out.println(key + ": " + value);
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output
Prodicts List
5: Prodict 5
4: Prodict 4
1: Prodict 1
3: Prodict 3
2: Prodict 2
0 comments:
Post a Comment