Java Columns - 6
public int compareTo ( HelloWorld anotherHelloWorld ) {
java.lang.Integer lVal = counter;
java.lang.Integer rVal = anotherHelloWorld.counter;
if ( lVal.intValue() > rVal.intValue() ) {
else if (lVal.intValue() < rVal.intValue() ) {
return toString().compareTo
( anotherHelloWorld.toString() );
Notes:
The explanation lies within the compareTo() method that was written as part of the HelloWorld class. This is the method name that ASA calls when it wants to compare two objects, and it must return +1 for "this object is greater than the other one", -1 for "less than" and 0 for "equal". In this example the counter field is used to answer the question, and if the to counter values are the same, the toString() values are used.