java arraylist | Sololearn: Learn to code for FREE!

+1

java arraylist

Should we add datatype ArrayList<integer> arraylist? or automatic goes integer if we dont mentions it?

4/23/2019 2:34:55 PM

Tzion

1 Answer

New Answer

+4

Elements in an ArrayList are objects. It doesnt support primitive data types (int, double,... ) so you have to use an equivalent wrapper class (Interger, Double, String, Boolean,...). You always have to mention it ! Like this : ArrayList<Integer> numbers = new ArrayList<>();