Created
May 28, 2020 17:31
-
-
Save prashant4224/c60bcfa70ae5051aabc4360735f40ec6 to your computer and use it in GitHub Desktop.
This file contains 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
/* Immutable Class */ | |
public final class Box { | |
private final String key; | |
private final String value; | |
private final HashMap<String, String> hm; | |
public Box(String key, String value, HashMap<String, String> hm) { | |
this.key = key; | |
this.value = value; | |
HashMap<String, String> hmTest = new HashMap<>(); | |
for (Map.Entry<String, String> hmEntry : hm.entrySet()){ | |
htTest.put(hmEntry.getKey(), hmEntry.getValue()); | |
} | |
this.hm = hmTest; | |
} | |
//No setters | |
public String getKey() { | |
return key; | |
} | |
public String getValue() { | |
return value; | |
} | |
public HashMap<String, String> getHm() { | |
return (HashMap<String, String>)hm.clone(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment