-------------------------------------- Java Sag is under construction: How do I compare string regardless their case?
Please inform us if you find a non good advertisement : info.enim dot gmail.com

Best Web Hosting

dimanche 6 mai 2012

How do I compare string regardless their case?

Here is an example of comparing two string for equality without considering their case sensitivity.
package org.kodejava.example.lang;

public class EqualsIgnoreCase {
    public static void main(String[] args) {
        String uppercase = "ABCDEFGHI";
        String mixed = "aBCdEFghI";

        //
        // To compare two string equality regarding it case use the
        // String.equalsIgnoreCase method.
        //

        if (uppercase.equalsIgnoreCase(mixed)) {
            System.out.println("Uppercase and Mixed equals.");
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire

Best Web Hosting