CharSequence of characters in String can be compared by contentEquals() method in java. contentEquals() method returns value in boolean. If character of sequence is found in string, it will return true, otherwise false. Use of String contentEquals() in java is shown below.
Example of String contentEquals() in java
public class StringContentEqualsExample { public static void main(String[] args) { String string = "java contentequals"; boolean checkCondition1 = string.contentEquals("java contentequals"); System.out.println("Result matched :"+checkCondition1); boolean checkCondition2 = string.contentEquals("java content"); System.out.println("Result not matched :"+checkCondition2); } }
Output
Result matched :true
Result not matched :false
Tags: String



Link to Us