import java.util.Map;
class Test {
public static void main(String[] args) {
Map<String, String> env = System.getenv();
System.out.println(env);
env.put("ID", "1");
}
}
I am adding some key value pairs in the map while initializing and then again adding one key value pair so what is wrong with the program?
No you cannot modify the returned map.
System#getEnv() returns unmodifiable map
Returns an unmodifiable string map view of the current system environment.
The reason being is that the map contains info about system that being run and you cannot simply add info programatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With