Question: Java The following class is given: import java.util.Arrays; public class StringImproved { / * * XU 0 4 * Field Detail * The storage for

"Java
The following class is given:
import java.util.Arrays;
public class StringImproved {
/**
XU04* Field Detail
* The storage for the characters in the StringImproved class
*/
private char[] charArray;
//Initialize storage string
public StringImproved(int size){
if(size <1){
System.out.println(""Size should be a positive number"");
}
charArray = new char[size];
}
public static void main(String[] args){
// TODO Auto-generated method stub
StringImproved stringImproved = new StringImproved(5);
System.out.println(stringImproved.append(""abcde""));
System.out.println(stringImproved);
}
}
Write the following methods for the class:
1)endsWith
public boolean endsWith(java.lang.String subString)
Check if the StringImproved object ends with the nominated string.
Difficulty 6/10
Parameters:
subString - The string to check.
Returns:
true If found, false otherwise.
2) increaseArray
private boolean increaseArray(int newSize)
Increase the capacity of the array to accommodate a different size string. This method is a private method, to be used
internally whenever the size of the array required is different than the current array. This method will not alter the contents of
the current character array. This method resizes it to the new size specified. If the new size is smaller than the current size it
will fail.
Difficulty 3/10
Parameters:
newSize - The new size of the array.
Returns:
True if successful false if not.
3) insert
public boolean insert(java.lang.String insertionString,
int index)
Insert the nominated string at the index.
Difficulty 7/10
Parameters:
insertionString - The string to insert into StringImproved object.
index - The position to insert at.
Returns:
True if successful false otherwise."

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 Programming Questions!