the source of the line is provided below, i understand what v.compareTo(w) does but i am curious as to what influence the < 0 has, does it not allow it to return if compareTo returns 1 which is greater than 0? does it not return if anything if compareTo returns 0 because it is equal to 0?

private static boolean less(Comparable v, Comparable w)   
{  
    return v.compareTo(w) < 0; 
}  

compareTo returns an int...
v<w returns -1
v==w returns 0
v>w returns +1

so if v is less than w, compareTo will return -1, and line 3 will return true. Otherwize compareTo will return 0 or+1, and line 3 will return false.

This is the usual way to sort lists of stuff, and a number of the C++, C#, and Java (as well as other OO languages) use this method to determine where to insert an element in a map or other sorted list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.