+ 1

java arraylist

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

23rd Apr 2019, 2:34 PM
Tzion
Tzion - avatar
1 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<>();
23rd Apr 2019, 7:36 PM
Svarog