java arraylist | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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 Réponse
+ 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