You are to write a program name Driver.java that uses an ArrayList.jav class that you must write with the following requirements: The class must be written to accept any type of Objects. And the following must be implemented i.e.

  • One default constructor that will create an arraylist object with a default size of 10 public arraylist()
  • Another constructor that accepts a parameter of type int and sets the size to this parameter public arraylist(int n)
  • A method that allows you to place a value at the end of the arraylist public void add(Object x)
  • A method that allows you to place a value at a given location public void add(int index, Object x)
  • A method that allows you to retrieve a value from a given location public Object get(int index)
  • A method that allows you get the number of elements currently in the arraylist public int size()
  • A method would test to see if the arraylist is empty public boolean isEmpty()
  • A method that see if a particular object exist in the arraylist public boolean isIn(Object ob)
  • A method that will return the location of first occurrence of an Object starting from location 0 public int find (Object n)
  • A method that will remove the first occurrence of an Object starting from location 0 public void remove (Object n)

Now, write the driver program ( the above mentioned Driver.java class with the public static void main(String[] args) method ) to test the arraylist data structure you just created. That is, you must test all ten of the above methods. Start off by filling the ArrayList with 50 randomly generated Integer numbers ranging from 1 20. Now, for those that are returning a value, print out the returned value to the screen and for those that are not returning a value, print a message that indicate if it successfully completed its task.

Remember The size function should be based upon the actual number of elements you have in the arraylist.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.