Question: package hw2; /** * A class that mimics how Java's String class behaves. */ public class MyString { private char[] data; /** * Construcs a

package hw2;

/**

* A class that mimics how Java's String class behaves.

*/

public class MyString {

private char[] data;

/**

* Construcs a MyString object to represent the text in

* string

* @param string the String we are representing.

*/

public MyString(String string) {

// TODO

}

/**

* A lexicographical comparison of this Mystring to other.

* The comparison is case sensitive, meaning it might not return the correct answer

* if the text being compared isn't all the same case.

*

* @param other the MyString to compare against.

* @return a negative number if this appears before other

* in the dictionary, a positive number if this appears after

* other in the dictonary, and 0 if this and other

* represent the same String

*/

public int compareTo(MyString other) {

// TODO

return 0;

}

public char charAt(int i) {

// TODO

return '\0';

}

public int length() {

// TODO

return -1;

}

public int indexOf(char c) {

// TODO

return -2;

}

@Override

public boolean equals(Object obj) {

// TODO

return false;

}

}

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