Question: Write a Java program that reads elements into the string array list Display the size of the string array list. Clone the array list. Add

Write a Java program that reads elements into the string array list

  • Display the size of the string array list.
  • Clone the array list.
  • Add an element into cloned array list at the given index.
  • Sort the cloned array list.
  • Replace an element from the array list.
  • Remove an element from the array list.
  • Search for an element in the array list and return a boolean value.
  • Print the array list in Reverse Order

Run-single

Enter arraylist element or enter quit to stop: Nissan

Enter arraylist element or enter quit to stop: Acura

Enter arraylist element or enter quit to stop: Bently

Enter arraylist element or enter quit to stop: Ferari

Enter arraylist element or enter quit to stop: Ford

Enter arraylist element or enter quit to stop: Toyota

Enter arraylist element or enter quit to stop: quit

--------ArrayList Method----------

*****1. Size********

The size of the array list is : 6

*****2. Display********

The size of the array list is : 6

Nissan Acura Bently Ferari Ford Toyota

---------Clone Method---------

*****3. Add element to index of cloned array********

Enter index: 1

Add element at 1: Jeep

--------Original array list elements-------

Nissan Acura Bently Ferari Ford Toyota

--------Cloned Array list elements after adding and sorting-------

Acura Bently Ferari Ford Jeep Nissan Toyota

***** Replace element at index 2: Lamborgini********

--------array List after replacing an element-------

Nissan Acura Lamborgini Ferari Ford Toyota

--------4. Remove an element******

-------- Array list after removing an element-------

Nissan Lamborgini Ferari Ford Toyota

--------5. Check if the list Contain element******

Enter the element you want to check:

Ford

Check resulttrue

--------6. Displaying list in reverse order******

Toyota Ford Ferari Lamborgini Nissan

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!