I'm facing a problem using ArrayList. I'm using an ArrayList with this content :
String, int, HashTable, HashTable
The HashTables are formed with a String key and an int value.
At some point in my program I need to set the value of the two HashTable. If I set ArrayList(2) (so first hashtable) with a HashTable h_gain for example and then I clear h_gain, the value assigned before with the right content is set to null (cause h_gain is now empty).
a_j1.set(2, h_gain);
Hashtable<String, Integer> h_tmp2 = (Hashtable<String, Integer>) a_j1.get(2);
// Gives the right value - like 1000 for example
System.out.println("TESSSSSSSSSSSSSST " + h_tmp2.get("En plein"));
h_gain.clear();
// Gives me null
h_tmp2 = (Hashtable<String, Integer>) a_j1.get(2);
System.out.println("TESSSSSSSSSSSSSST " + h_tmp2.get("En plein"));
I don't get why it acts like this. If I simply do it with a variable the behavior is more like expected
int val1 = 10
int val2 = val1 // val2 = 10
val1 = 0 // Well, val2 is still = 10
Any help on this?