Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Java code to implement a reduced version of a List data structure. A List, like a top-ten list or a grocery list, is a

image text in transcribed

Write Java code to implement a reduced version of a "List" data structure. A List, like a top-ten list or a grocery list, is a collection of items in a defined order. It is collection, like a set, except that each item has an assigned position in the list, and duplicate entries are permitted Note that items in a list are always in consecutive positions, there are no empty spaces. If an item is inserted in the second position, the items following it are pushed down, so that the former second item is now the third, and so on. WARNING: Notice that positions begin at one, not zero. For this problem, define a List class to model a list of any size of Strings. Use an array to store the elements of the list. Start with a fixed-size array of 50), and allow it to grow if necessary Can't use array list Write the code for the following member functions: my a constructor that creates an empty list. an accessor function to return the String at a given position (from one to the size of the list) without changing the list and return null if there is an attempt to access a position outside the current list.) e a method to insert a given String at a given position (from one to a maximum of one more than the size of the list). (Ignore requests to insert numbers at positions outside the current list, with one exception: a request to insert a number at position N+1, where N is the size of the list, will add an item to the end of the list.) a method to return the position of a given String in the list the position of the first occurrence, or zero if not found). (To compare two Strings, use the 'equals' method.) Shiva method to return a single String summarizing the entire contents of the list. There is no main program specification and no input from the user. This does not have to be compiled and tested. Just write the code for the List class and let me look it over to make comments. Turn in the assignment on a piece of paper

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

More Books

Students also viewed these Databases questions