Java String .contentEquals ( CharSequence cs)

Syntax

String.contentEquals(CharSequence cs) has the following syntax.

public boolean contentEquals(CharSequence cs)

Example

In the following code shows how to use String.contentEquals(CharSequence cs) method.


public class Main {
/*  w  ww .j a v  a  2s . c  om*/
  public static void main(String[] args) {

    String str1 = "java2s.com", str2 = "Java2s.com";
    CharSequence cs = "java2s.com";
    
    System.out.println("Method returns: " + str1.contentEquals("java2s.com"));
    
    System.out.println("Method returns: " + str1.contentEquals(cs));
  
    System.out.println("Method returns: " + str2.contentEquals("12345"));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable