how is VM choosing which one to delete (among "hi" and s in line no 10 and 12 respectively) ? because when i am commenting out test.add("hi"); i am seeing that it is s that gets removed. But when they are both active,it is "hi" that is removed. What is the rule or logic behind this?
Since i am learning collections for the first time, it worries me a lot if the theory included in Sierra-Bates is enough.They gave very good introductions on comparable,comparator,equals,hashcode etc.But theories about List,Map, Set or its implementing classes are a bit...well a lot obscured . Do i need in-depth knowledge in those sections too for the sake of the exam?
"I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times" - Bruce Lee
Removes the first occurrence of the specified element from this list, if it is present. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).
This is statement given in Java SE 6.0 API documentation for class ArrayList containing method remove(Object o). Even if both strings are different it will work.
1)The Underlying datastructure for ArrayList is
Resizeable array or Growable Array.
2) Insertion order is Preserved (i.e., order of elements inserted into arraylist).
3)Duplicatate Objects are allowed.
4)Hetrogenius Objects are Allowed.
5)null insertion is possible.