java arraylist | Sololearn: Learn to code for FREE!


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


1 Answer

New Answer


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<>();