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
returnOne
In this problem, you're practicing how to instantiate a list in Java and how to use the add method.
Complete the method's logic returnOne
that declares and instantiates an ArrayList of Integers with one element, the number 3.
Return the entire list.
Example: Adding to an ArrayList
//Declare and instantiate an ArrayList
ArrayList<Integer> myList = new ArrayList<Integer>();
//add 5 to the end of the list using the add method
myList.add(5);
The following are methods of a list that can be used to manipulate the contained data.