You can't compare objects, including Strings or in this case Sequence objects, using < or any other operator besides == and != . You'll need a comparison function. For example, you might give Sequence a method like
Now instead of using "<", you can say
if (seqArray[i].compare(seqArray[minPos]) < 0)
I don't know if this is homework and you're obligated to write your own sort method, but note that the java.util.Arrays class has some lovely static sort() methods to sort arrays of many types. To sort an array of some user-defined type, you need to make that type implement the java.util.Comparable interface which has one method, compareTo(), which looks very much like the above compare() method. Note that String already implements Comparable.
There's actually another alternative to implementing Comparable -- you can instead create another class that implements Comparator and use an instance of that to direct the sorting; this is not any easier.
Well, does Sequence have a charAt(int) method? I notice that the method uses charAt(), but the error message says char(). The latter would not be a legal method name, as it's a keyword (the name of a built-in type.) [ December 08, 2004: Message edited by: Ernest Friedman-Hill ]
Joined: Nov 10, 2004
Okay, I came up with a better method to use selection sort but (funny, thing is) i am getting the same error. Ha!Ha!Ha! i am going to need a compareTo method, and i have been trying to write it, hopefully someone can walk me through it.