Question: 1. Create an ArrayList name myPets that will hold pet names. 2. Create an ArrayList name myPets that will hold pet names. 3. Write code
1. Create an ArrayList name myPets that will hold pet names.
2. Create an ArrayList name myPets that will hold pet names.
3. Write code that will add "Ollie" to myPets at index 1.
4. Write code that will print the elements in myPets.
5. Write code that will obtain the size of myPets and store it in num.
6. Write code that will delete the last element in myPets.
7. Consider the following code segment. Trace what happens in memory. What is the output?
int [] A = new int [1];
int [] B = new int [30];
B[9] = 31;
A = B;
A[9] = 20;
B[9] = 12;
System.out.println (A[9]);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
