@Override
public int compareTo(StockItem o){
if(o != null)
return this.itemName.compareTo(o.getItemName());
}
I know, it is fairly simple to many of you, yet I would like to clear the doubts. At first sight, it looks like the recursive function or it is like calling the parent compareTo function.
However, after the research, I tend to think those two compareTo methods are different. The first one that is actually being overridden is from the Comparable interface, and the second is from the String class. Thus, we can call compareTo from the String class while overriding the Comparable compareTo method.
Please, confirm my thoughts. Thank you.