Question: Using MethodsGiven String variables stored in foodItem 1 , foodItem 2 , foodItem 3 , foodItem 4 , foodItem 5 , foodItem 6 , and
Using MethodsGiven String variables stored in foodItem foodItem foodItem foodItem foodItem foodItem and foodItem do the following:
Declare a new ArrayList called pantry
Put the given variables into the pantry
Print to the console the following concatenations of a String and the results of a method:
Print "Size: a method that will return the size of the List
Print "First element: a method that will retrieve the first element in the List
Print Is it Empty: a method that will return a Boolean after checking if the List is empty
import java.io;
import java.util.;
public class CodingQuestion
public static void mainString args
Scanner in new ScannerSystemin;
String foodItem innextLine;
String foodItem innextLine;
String foodItem innextLine;
String foodItem innextLine;
String foodItem innextLine;
String foodItem innextLine;
String foodItem innextLine;
DO NOT CHANGE THE CODE ABOVE THIS LINE
WRITE YOUR CODE HERE
DO NOT CHANGE CODE BELOW THIS LINE
end of main
STDOUT
Expected STDOUT
Size:
Firstelement:Apples
IsitEmpty:false
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
