Question: Write a Java program with the following: a ) declare an ArrayList of Strings named myArrayList b ) add Sam to myArrayList; c ) add
Write a Java program with the following:
a declare an ArrayList of Strings named myArrayList
b add "Sam" to myArrayList;
c add "Samantha" to myArrayList;
d print the length of myArrayList
e change the first element of myArrayList to "Sameer"
f check if myArrayList is empty; if it is print "List is Empty"; otherwise, print the contents of myArrayList using the "enhanced loop"
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
