when I use ArrayList in Java, there are some things that I do not understand. Here is my initialization code:
ArrayList<Integer> list = new ArrayList <Integer> ();
list.add (0);
list.add (1);
sometimes I need to delete an object by its index:
list.remove (0) // delete the object in the first box
but sometimes I want to delete an object by its contents:
list.remove (0) // delete the object HAS Which value of 0
this code is very ambiguous. To clarify what I want to do it in code, I specify the type like this:
list.remove ((Object) 0) // delete the object which has a value of 0
If I do not AC, the only way to know which methods are called is to put the mouse pointer on the method to see:
java.util.ArrayList.remove boolean (Object object)
Java But how does it make difference?
is there a method pointer?
Is there a less ambiguous way to do this?
thank you very much, sorry for my English.
PS: I should say that I finally used SparseIntArray but I am curiously
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…