String Length Comparable Parameterized
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<MyString> interface, returning 1 for a positive result and -1
for a negative result.
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
Because we are using the type parameter
MyString to the
compareTo accepts an
MyString as an argument.
MyString passed to
compareTo will not be