Java String .contentEquals ( StringBuffer sb)

Syntax

String.contentEquals(StringBuffer sb) has the following syntax.

public boolean contentEquals(StringBuffer sb)

Example

In the following code shows how to use String.contentEquals(StringBuffer sb) method.


public class Main {
//w ww .j  a va 2s.  c  o  m
  public static void main(String[] args) {
 
    String str1 = "java2s.com";
    String str2 = "java2s.com";
    
    StringBuffer strbuf = new StringBuffer(str1);
    System.out.println("Method returns : " + str2.contentEquals(strbuf));
  
    str2 = str1.toUpperCase();
    System.out.println("Method returns : " + str2.contentEquals(strbuf));
  }
}

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