String Compare in Java

This Program uses the compareTo() function inorder to compare the strings which given by the users in two variables.
public class StringCompare{
 
  public static void main(String args[]){
 
  String str = "Forget Code";
  String anotherString = "forget code";
  Object objStr = str;
  System.out.println( str.compareTo(anotherString) );
  System.out.println( str.compareToIgnoreCase(anotherString) );
  System.out.println( str.compareTo(objStr) );
 
  }
}