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
varsToList
In this problem, you're practicing how to create a list and add elements to it that are stored in variables rather than literal values.
Complete the method varsToList
which takes in 2 integer parameters and returns them in a list in their respective order.
For example, a call to varsToList(1, 2)
returns a list with the element at index 0 is 1 and the element at index 1 is 2.
Syntax:
ArrayList<DataType> name = new ArrayList<DataType>();
The following are methods of a list that can be used to manipulate the contained data.