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
XU Field Detail
The storage for the characters in the StringImproved class
private char charArray;
Initialize storage string
public StringImprovedint size
ifsize
System.out.printlnSize should be a positive number"";
charArray new charsize;
public static void mainString args
TODO Autogenerated method stub
StringImproved stringImproved new StringImproved;
System.out.printlnstringImprovedappendabcde;
System.out.printlnstringImproved;
Write the following methods for the class:
endsWith
public boolean endsWithjavalang.String subString
Check if the StringImproved object ends with the nominated string.
Difficulty
Parameters:
subString The string to check.
Returns:
true If found, false otherwise.
increaseArray
private boolean increaseArrayint 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
Parameters:
newSize The new size of the array.
Returns:
True if successful false if not.
insert
public boolean insertjavalang.String insertionString,
int index
Insert the nominated string at the index.
Difficulty
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
