- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByReference.java
More file actions
Latest commit
31 lines (22 loc) · 773 Bytes
/
Copy pathByReference.java
File metadata and controls
31 lines (22 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
packageexamples;
importjava.util.HashMap;
importjava.util.Map;
publicclassByReference {
publicstaticvoidmain(String[] args) {
Map<String, String> map = newHashMap<>();
map.put("key1", "value1");
ConfigHolderconfigHolder = newConfigHolder(map);
System.out.println("The config is : " + configHolder.getConfig());
map.put("key2", "value2");
System.out.println("The config after modifying the initial map : " + configHolder.getConfig());
}
staticclassConfigHolder {
privatefinalMap<String, String> conf;
ConfigHolder(Map<String, String> conf) {
this.conf = conf;
}
publicMap<String, String> getConfig() {
returnconf;
}
}
}