title: Java comparable interface compareTo(Object o), what is object o?
body: <p>Beginner, can't seem to wrap my head around this.</p>
  
  <p>Item Class</p>
  
  <pre><code>public class Item implements Comparable {
  
  private int number;
  private String description;
  
  public Item(int num, String descript){
      this.number = num;
      this.description = descript;
  }
  
  public int getNumber(){
      return number;
  }
  
  public String getDescription(){
      return description;
  }
  
  @Override public int compareTo(Object o){
      Item i = (Item) o;
      if(this.getNumber() &lt; i.getNumber())
          return -1;
  
      if(this.getNumber() &gt; i.getNumber())
          return 1;
  
      return 0;
  }
  
  }
  </code></pre>
  
  <p>Main method</p>
  
  <pre><code>Item[] items = new Item[3];
      items[0] = new Item(102, "Duct Tape");
      items[1] = new Item(103, "Bailing wire");
      items[2] = new Item(101, "Chewing Gum");
  
      Arrays.sort(items);
  
      for (Item i : items){
          System.out.println(i.getNumber() + ": " + i.getDescription());
      }
  </code></pre>
  
  <p>When the main method instantiate <code>items[0] = new Item(102, "Duct Tape");</code> Which goes through Item constructor to set current variable number, description.</p>
  
  <p>My problem is I can't seem to understand what is being passed in the compareTo argument, therefore I can't seem to understand <code>this.getNumber() &lt; i.getNumber()</code> is doing...</p>
  
  <p>Return a negative number if current object is less than passed object?</p>
  
  <p>any help is much appreciated. </p>