Created
January 27, 2020 19:57
-
-
Save benjjo/dd3a2637f8d73771004afd1f36f52f24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| class Test{ | |
| public static final Map<String,Integer> MYHASH; | |
| static{ | |
| Hashtable<String,Integer> tmp = | |
| new Hashtable<String,Integer>(); | |
| tmp.put("A",65); | |
| tmp.put("C",67); | |
| MYHASH = Collections.unmodifiableMap(tmp); | |
| } | |
| public static void main(String[] args){ | |
| System.out.println(MYHASH.get("A")); | |
| //this will throw | |
| //java.lang.UnsupportedOperationException | |
| MYHASH.put("B",66); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment