Back To Java String Class Index
//program to demonstrate compareto method of String class example 2 public class stringcompareto2 { public static void main(String[] args) { // TODO Auto-generated method stub String a=new String("abcdef"); String b=new String("abcdef"); if(a.compareTo(b)==0) { System.out.println(a + " and " + b + " are equal"); } else { System.out.println(a + " and " + b + " are not equal"); } } } }