Table of Contents
String’s contentEquals method is used to compare String with StringBuffer. It returns boolean datatype.
When you run above program, you will get below output:
Method syntax:
1 2 3 |
public boolean contentEquals(StringBuffer sb) |
String contentEquals Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
package org.arpit.java2blog; public class StringContentEqualsExample { public static void main(String[] args) { String str1 = "java2blog"; String str2="Hello world from java2blog"; String str3="JAVA2BLOG"; StringBuffer sb=new StringBuffer("java2blog"); System.out.println(str1.contentEquals(sb)); System.out.println(str2.contentEquals(sb)); System.out.println(str3.contentEquals(sb)); } } |
1 2 3 4 5 |
true false false |
Please note that contentEquals method is case sensitive as you can see in above example
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.