How to check that a String value is equal to that of a String Buffer with the contentEquals() method
Coding River
How to check whether the String value stored in a String is equal to that of a String Buffer Using the Java contentEquals() method
In this video, we will talk about the Java contentEquals() method, which is used to compare a given String with a String Buffer and returns a Boolean value. It returns true if there is a match between the given String and the String Buffer and it returns false if there is no match. Let me show you how to use this example with the help of example
String str1 = “I love programming”; StringBuffer str2 = new StringBuffer(“I love programming”); System.out.println(str1.contentEquals(str2)); If we run this program, it will return "true" in the console, meaning that the String str1 is the same as the one in the String Buffer str2
If you change the characters in str2 StringBuffer str2 = “love programming”; and do a System.out.println(str1.contentEquals(str2)); The result in the console will be "false"
#codingriver #java #programming ... https://www.youtube.com/watch?v=INQR80HTee8
5096625 Bytes