Java Blog

 
 
 
 public class JAVA_048
 {
    public static void main(String[] args)
    {
       String String1=\"A\";
       String String2=\"To\";
       String String3=\"Z\";

       System.out.println(\"String1 : \" + String1);
       System.out.println(\"String2 : \" + String2);
       System.out.println(\"String3 : \" + String3);

       if(String1.compareTo(String3)<0)
          System.out.println(\"String1 is less than String3\");

       else
       {
          if(String1.compareTo(String3)>0)
             System.out.println(\"String1 is greater than String3\");

          else
             System.out.println(\"String1 is equal to String3\");
       }

       if(String2.compareTo(String1)<0)
          System.out.println(\"String1 is less than String1\");

       else
       {
          if(String2.compareTo(String1)>0)
             System.out.println(\"String2 is greater than String1\");

          else
             System.out.println(\"String2 is equal to String1\");
       }
    }
 }