Java String contentEquals Example
String class contentEquals method example
String class contentEquals method example. This example shows you how to use contentEquals method.This method Compares string to the specified CharSequence.
Here is the code:-
/**
* @(#) ContentsEquals.java
*Program that Compares this string to the specified object.
* @Version 01-May-2008
* @author Rose India Team
*/
public class ContentsEquals
{
public static void main(String args[])
{
String str = "Hello World";
String anotherString = "Hello World";
//creating object of anotherString
Object obj = anotherString;
// Compares this string to the specified object,returns true if equals else returns false
System.out.println( str.contentEquals(anotherString) );
}
} |
-
|