Question: java Let's begin building a simple list implementation that uses arrays to store the values. Create a class simpleArrayL ist with a public constructor that
Let's begin building a simple list implementation that uses arrays to store the values. Create a class simpleArrayL ist with a public constructor that initializes the list using a passed array of object references. assert that the passed array is not nuzl. Next, implement: 1. Object get(int), which takes an int index and returns the object at that index 2. void set(int, Object), which takes an int index and an object reference and sets that value at the index to the passed reference. Both your get and set method should assert that the index passed is valid for that SimpleArrayList. Here's an example of how your SimpleArrayL ist should work: 1 SimpleArraylist list = new SimpleArraylist(new int [],{1,2,5}); 2 System. out.println(list.get(1)); // prints 2 3 List.set( 1,6); 4 System. out.println(list.get (1));// prints 6 5. System, out.println(list.get( 6));// prints 1 6. System, out.println(list.get (4));// generates an assertion error Don't overthink this! Both get and set should be two lines of code (including one for the assert). A This is a practice problem and not worth points toward your grade. You will be able to view the solution walkthrough once you either complete the problem or attempt it 8 more times
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
