String Compare i JAVA programming


package SolveProblem;

public class StringCompare {

    public static void main(String[] args) {
        String s1="Alamgir";
        String s2="Alamgir";
        int a=s1.compareTo(s2);////// It is case sensitive
       
        //If two string are same then return 0
        System.out.println(a);
       
        //Compare two string ignore case sensitive
       
        int b=s1.compareToIgnoreCase(s2);
        System.out.println(b);
    }

}

No comments:

Post a Comment