I have created a new HashMap Object say. Now I pass this object to a method where I change the reference of the variable to some other hashmap object .The reference to this new object is not reflected once the method is completed
Example :
Map<String, Boolean> map = new HashMap<String, Boolean>();
changerefofMap(HashMap<String, Boolean>() map)
{
map=methodwhichreturnSomeMap();
System.out.println(map.size()); //returns 2
}
System.out.println(map.size()); //returns 0
I don't understand why the reference is not getting changed.