String Length Comparable
Let's get some practice implementing a known interface.
Create a public class named
MyString should provide a public constructor that accepts a single
You should reject
Strings in your constructor using
MyString should also implement the Java
Comparable interface, returning 1 for a positive result and -1 for a
Strings are compared lexicographically: "aaa" comes before "z".
MyString should compare instances based on the length of its stored
MyString("aaa") should come after
MyString("z"), since "aaa" is longer than "z".
You will probably need to review the documentation for
compareTo accepts an
Object as an argument, but you can reject non-
MyString arguments using