Completion requirements
Read this chapter about lists and the useful methods that are available for adding and inserting elements into a list.
19. Wrapper Classes
Answer:
No.
The non-empty cells of an ArrayList
must contain object references (or null
).
Wrapper Classes
Wrapper Classes
int
into an ArrayList
, put the int
inside of an Integer
object. Now the object can be put into an ArrayList
. The following program builds a list of integers and then writes them out.
|
The program writes out:
1 3 17 29
The picture emphasizes that the ArrayList
contains an array of object references, as always. It shows the int
s each contained in a little box that represents the wrapper object.
Question 19:
Would this statement work in the program?
data.add( 44 );