Question: Please code this in java! Thank You!! Write a class named FancyStringArray. An object of this class should be designed to store some Strings. Internally,

Please code this in java! Thank You!!

Please code this in java! Thank You!! Write a class named FancyStringArray.

Write a class named FancyStringArray. An object of this class should be designed to store some Strings. Internally, these Strings should be stored in an array. capacity, then the FancyStringArray should have a capacity of 10. Separate from the notion of capacity, there is also a notion of size. The size of a FancyStringArray is the number of elements that it is currently storing. stored at indexes 0 through 2. When we add a fourth element, it should be placed at index 3. The class should have the following constructors: - public FancyStringArray() - public FancyStringArray(int capacity) The class should have the following methods: - public int size() - public void add(String element) - public String get(int index) // returns the element at the specified index - public String set(int index, String newElement) // replaces the old element at the specified index with the new element, and returns the old element - public boolean contains(String s) // determines whether this FancyStringArray contains s here: two FancyStringArrays can be considered equal even if they have different capacities. Throwing exceptions: - The second constructor should throw an IllegalArgumentException if the provided capacity is negative. - The add method should throw an IllegalStateException if the array is full. - The get and set methods should throw an IndexOutOfBoundsException if the provided index is negative, or if it is greater than or equal to the size. Note: do not use ArrayList (or any other kind of List or Collection) in the FancyStringArray class

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!