I have a hashMap. Its key is some string object, the value is a fixed size string array. Initially I need all the elements in the string be null or "" (empty string). Then I want to retrieve a value from a hashmap and modify that string array. Then I want to retrieve the modified string which is the value in the hashmap. Here is my code --
1. String a = (String)hm.get("a"); In this line I cast the retrieved object into string and assign it to a new string object "a", then I modify "a" array. Does it just modify the new array "a" or does it actually modify the array object that is stored as the value
for key "a" ? My output shows it works fine but I want to understand why.
2. code "new string" automatically default the elements to null for this array. Is ther fast way to create a string array with "" (empty string) as default value ? The simple the better. How ?