Question
(java) (Java) convert the array in the class in the code given below into a Linked LIst. ---- class StringList{ private int size; private int
(java)
(Java)
convert the array in the class in the code given below into a Linked LIst.
----
class StringList{ private int size; private int count; private String List[]; public StringList(){ this.size=10; List=new String[size]; count=0; } public StringList(int size){ this.size=size; List=new String[size]; count=0; } public boolean isEmpty(){ return count==0?true:false; } public boolean isFull(){ return count==size?true:false; } public int size(){ return count; } public void clear(){ count=0; } public String StringRetrieve(int position){ if(position<0||position>count){ throw new RuntimeException("Invalid Position"); } return List[position]; } public void StringReplace(String newStr,int position){ if(position<0||position>count){ throw new RuntimeException("Invalid Position"); } List[position] = newStr; } public void StringRemove(int position){ if(position<0||position>count){ throw new RuntimeException("Invalid Position"); } for(int i=position;i List[i]=List[i+1]; count--; } } public void insert(String newStr,int position){ if(position<0||position>size){ throw new RuntimeException("Invalid Position"); } if(position==count){ List[position]=newStr; } else if(position for(int i=position;i List[i+1]=List[i]; } List[position]=newStr; } count++; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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