Students, please be sure to log in. This site does not use cookies and does not track/store work submitted when not signed in.
Unit 7 Problems
Java Reference Sheet
returnTwo
In this problem, you're practicing how to instantiate a list in Java as well as how to use the add method.
Complete the method returnTwo
below that returns a list containing two integers 5 and 4 in that order.
Syntax:
ArrayList<DataType> name = new ArrayList<DataType>();
To add to a list, use the add method of the list.
Example:
ArrayList<String> names = new ArrayList<String>();
names.add("Jill");
The following are methods of a list that can be used to manipulate the contained data.