Page 35 - Abstract Class, Interface & Struktur Data
P. 35
Other Types
• Elements in an ArrayList are actually objects. In the examples above, we created elements (objects) of type
"String". Remember that a String in Java is an object (not a primitive type). To use other types, such as int, you
must specify an equivalent wrapper class: Integer. For other primitive types, use: Boolean for boolean, Character
for char, Double for double, etc:
• Create an ArrayList to store numbers (add elements of type Integer):