I know that, casting is not the correct word when
java.lang.Object
-> java.util.concurrent.CopyOnWriteArrayList<E>
and
java.lang.Object
-> java.util.AbstractCollection<E>
-> java.util.AbstractList<E>
-> java.util.ArrayList<E>
But what I want is adding the behavior of the CopyOnWriteArrayList
to the ArrayList
.
Eg :
I want to do following. But tstArry is an ArrayList
. not a CopyOnWriteArrayList
for(TestCls testCls : tstArry)
if(testCls.getVal1().equals("a1"))
tstArry.remove(testCls);
Or is this the only way to get the job done?
for(int i = 0; i < tstArry.size(); i++)
if(tstArry.get(i).getVal1().equals("a1"))
tstArry.remove(i--);
tstArry is an ArrayList from a class that I haven't had the control on it. So, Please make the changing the type of ArrayList to another is the far most solution.