or I'd say "Hey, there's no reason why null shouldn't have square brackets, too, and write
public String toString()
return " xxx: [" + getXXX() + "]\n";
Originally posted by Jim Yingst:
[MdQ]: I think you could easily write a test to see if '1' or '-1' is always returned.
True - however such a test may give misleading results. It's very common to see compareTo() methods which return only -1, 0, or 1, and therefore it's quite possible that a test will show that the method "always" returns those values. But that just means that the tester hasn't tried enough different Comparable classes. (Hint: try comparing two String values.)
If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case, compareTo returns the difference of the lengths of the strings -- that is, the value:
before running tomcat in eclipse it was showing.
but now nor external tomcat home page is running nor eclipse's internal though on giving full path of file of any application it is perfectly fine.
But actually it seems to me, compareTo() returns only 0, 1, -1 even if the API spec does not explicitly mention it...So I could omit the transfomation which would reduce the amount of code. But, how can I be sure?