Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML

Search:
   Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML Facing Programming Problem? Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
Character Cases Ignoring case sensitiveness in java
In this section, you will learn how to compare two strings ignoring case sensitiveness Java provides the method that ignores cases, it only compare the character's sequence.
 
 

Character Cases Ignoring case sensitiveness in java

                         

In this section, you will learn how to compare two strings ignoring case sensitiveness  Java provides the method that ignores cases, it only compare the character's  sequence. The compareToIgnoreCase() method compares two strings and ignores its cases. This method returns an integer type value like:  a negative integer, a positive or zero.

Description of program:

The following program compares two strings and ignore these cases but it compares  the sequence of characters in the given string. In this program, three string types data have been used that have to be compared. Here the CharComp() method is applied for comparing strings. The compareToIgnoreCase() method compares strings and shows the given message.

Description of code:

compareToIgnoreCase(String str):
This method is used to compare two strings with ignored cases. It takes following arguments:

        str: This is the string that have to be compared. 

Here is the code of program:

import java.lang.*;

public class CharCompIgnoreCase{
  public static void main(String[] args) {
    System.out.println("Character comparation to ignore case example!");
    String str1 = "Vinod";
    String str2 = "Vinod";
    String str3 = "vinod";
    CharComp(str1, str2, str3);
  }
  public static void CharComp(String str1, String str2, String str3){
    System.out.println("String1 = " + str1);
    System.out.println("String2 = " + str2);
    System.out.println("String2 = " + str3);
    if(str1.compareToIgnoreCase(str2== 0){
      System.out.println("String1 and String2 are equal!");
    }
    else{
      System.out.println("String1 and String2 are not equal!");
    }
    if(str1.compareToIgnoreCase(str3== 0){
      System.out.println("String1 and String3 are equal!");
    }
    else{
      System.out.println("String1 and String3 are not equal!");
    }
    if(str2.compareToIgnoreCase(str3== 0){
      System.out.println("String2 and String3 are equal!");
    }
    else{
      System.out.println("String2 and String3 are not equal!");
    }
  }
}

Download this example.

Output of program:

C:\vinod\Math_package>javac CharCompIgnoreCase.java

C:\vinod\Math_package>java CharCompIgnoreCase
Character comparation to ignore case example!
String1 = Vinod
String2 = Vinod
String2 = vinod
String1 and String2 are equal!
String1 and String3 are equal!
String2 and String3 are equal!

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.