ComapareTo () method is provided by java.lang.string package that check the two
different String to character by character if both the String are same than
return 0 otherwise it return (-value) for each character.
Equals () Method is java. Object package Object Class Method that Check the two
Different object and return true or false
Example:
public class comptest { public static void main(String[] args) { String s = “javaâ€; String s1 = new String (“java1″); System.out.println(s.compareTo(s1)); System.out.println(s.equals(s1)); }} |