+ 1
java arraylist
Should we add datatype ArrayList<integer> arraylist? or automatic goes integer if we dont mentions it?
1 ответ
+ 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<>();