compareTo method java
<p>I'm working on homework and need someone to walk me through something. I am learning about arrays and basically I have an array that collects a lastname, firstname, and score.
I need to write a compareTo method that will compare the last name and then the firstname so the list could be sorted alphabetically starting with the last names and then if two people have the same last name then it will sort the first name.</p>

<p>I'm confused because all of the information in my book is comparing numbers and not objects or I guess Strings? I think strings are considered objects when working with arrays.
This is really confusing me so if somone can walk me through it I would appreciate it.
Here is what I have coded so far but I know it's wrong but it at least explains what I think I'm doing.</p>

<pre><code>    public int Compare(Object obj) // creating a method to compare 
{   
        Student s = (Student) obj; //creating a student object

        // I guess here I'm telling it to compare the last names?
        int studentCompare = this.lastName.compareTo(s.getLastName()); 

        if (studentCompare != 0)
            return studentCompare;
        else 
        {
            if (this.getLastName() &lt; s.getLastName())
                return - 1;

            if (this.getLastName() &gt; s.getLastName())
                return 1;
        }
        return 0;

}
</code></pre>

<p>I know the &lt; and > symbols are wrong but like I said my book only shows you how to us the <code>compareTo</code> method using numbers which I think is kind of unfair to expect me to understand how to compare objects. </p>
