Fix my java code
As discussed in class it is reasonable that the Java String class really stores the text that the String contains as an array of characters. This is the implementation that we will assume.
public MyString( String original) : this is the constructor for your class, it takes as input an instance of a Java String and breaks it into a character array. (See the method toCharArray in Java’s class String)
public int length() – This method returns the length, or number of characters in the string
public char charAt(int index) — given a valid index this method returns the character at that index. If an invalid
index is given your method should throw an “IndexOutOfBoundsException”, in the form
throw new IndexOutOfBoundsException(“Message”);
where “message” is the text you want printed with the exception
public MyString concat(MyString otherString) — Concatenates the specified string, “otherString”, to the end of this string object producing a new MyString.
public boolean endsWith( MyString suffix) — this method returns true if the test string ends with the specified suffix
public int indexOf( char ch) — Returns the index within this string of the first occurrence of the specified character “ch” , if “ch” is not present in the string the method returns -1
public int indexOf( MyString str) — Returns the index within this string of the first occurrence of the specified substring. If the substring is not present -1 is returned
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


