In an ArrayList for android such as the simplelistadapter I commonly see ArrayList<?>
and in some tutorials I've reviewed the <?>
is replaced by some value. But I'm still not quite sure what variable or qualifier this stands for.
It's called Generics.
For example, you can do this:
ArrayList<Integer> list = new ArrayList();
list.add(new Integer(1));
list.add(new Integer(2));
.....
Integer i = (Integer)list.get(1);
Or you can do:
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(new Integer(1));
list.add(new Integer(2));
.....
Integer i = list.get(1);
As you can see, no need for casting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With