Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make ArrayList that holds an unspecified number of objects. The object class should be created by you in a separate file. Make a new class
- Make ArrayList that holds an unspecified number of objects. The object class should be created by you in a separate file. Make a new class for this assignment- don't use a previous class.
- Your object class should be Comparable. Here's a quick tutorial on Comparable objects.(Links to an external site.) This will allow you to compare the objects using a compareTo method. It should also contain a toString method for ease of printing, an equals method, and any necessary accessors and modifiers.
- The objects should be added to the list in random order using whatever method you choose.
- Use a Merge Sort to sort the list (the code is easy to find in our books or online). The merge sort should be commented extensively to demonstrate your understanding of the algorithm. Do not use the Collections.sort() method.
- Print the list both before and after the sort.
MAKE AS SIMPLE AS POSSIBLE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Create a new class called MyObject that implements the Comparable interface Add necessary methods like compareTo toString equals accessors and modifie...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started