Search Java Programs

Wednesday, January 20, 2010

Java String equalsIgnoreCase Example

String class equalsIgnoreCase method example


String class equalsIgnoreCase method example:- This method demonstrates the working of equalsIgnoreCase method. this method returns a boolean value after examining the two String. this method's examines without considering case senstivity

Syntax:-equalsIgnoreCase(String anotherString)

Here is the code:-

/**
* @(#) EqualsIgnoreCaseString.java
* EqualsIgnoreCaseString class demonstrates the working of equalsIgnoreCase() method of String class of lang package
* @version 15-May-2008
* @author Rose India Team
*/



public class EqualsIgnoreCaseString {
public static void main(String args[]) {

String str = "koi mil gaya", str1 = "Koi mil gaya", str2 = "";
boolean result = str.equalsIgnoreCase(str1);
// Method compares two String leaving case Senstivity behind
//Strings str and str1 are equal therefore method here returns true
System.out.println("method returns true: " + result);

String str3 = new String("12234");

result = str.equalsIgnoreCase(str3);
//Strings str and str3 are not equal
System.out.println("false is returned: " + result);
}
}
Output of the program:-
method returns true: true
false is returned: false

No comments:

Post a Comment

Website Design by Mayuri Multimedia