Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Help!! (Interface, List stuff) Please help, thank you List https://cs1331.gitlab.io/fall2018/hw5/List.java Problem Description You will be implementing the methods from the interface, List, into the

JAVA Help!! (Interface, List stuff) Please help, thank you

image text in transcribed

List https://cs1331.gitlab.io/fall2018/hw5/List.javaimage text in transcribedimage text in transcribedimage text in transcribed

Problem Description You will be implementing the methods from the interface, List, into the concrete class, MyList. You will also be using IllegalArgumentexception and IndexoutofBoundsException. Make sure to check Piazza for updates. There will not be announcements about clarifications on homeworks. List This interface is already written and provided for you: List.java It has the following fields: int INITIAL_CAPACITY Represents the default initial capacity of our list. It has the following methods: void add (E e) Adds the passed-in element to the last position in the list and throws an IllegalArgumentException if e is null. Consider how you can store this list and the possible problems to account for when using this. E get(int index) Selects an element from the given index in the list. void replace(E e, E replacewith) Replaces all instances of e with replacewith in the list. This method throws an IllegalArgumentException if either of the passed-in elements are null. int remove (E e) Removes all instances of e and returns a count of how many instances were removed. The method throws an IllegalArgumentException if e is null. This method should also be ensuring that null elements are not left in the middle of the list. For example, if there is (1, 2, 3 and remove(2) is called then the list should not become (1, nul1, 3 int contains(E e) Checks to see how many instances of e are in the list and returns this count. The method throws an IllegalArgumentException if e is null. boolean isEmpty() Checks to see if there are any objects in the list. If there is at least one object, then this should return true. Otherwise, this should return false void clear() Should make the entire List empty; all objects are removed from the list. int size() Returns the number of non-null elements in the list. El] toArray(E[] e). Returns the array e that was input e should be filled with as many non null elements of the list as it can fit, starting from the beginning of the list (e.g. if e is length 3 and the list is (1,2,3,4,5),e should be returned as 1,2,3)'). Any extra spots in e should be set to null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions