This Java program demonstrates how to compare a string with a specified sequence of characters using the contentEquals() method of the String class.
public class Compare_Specified_Char { public static void main(String[] args) { String str1 = "Tutor Joes"; String str2 = "Computer Education"; CharSequence cs = "Tutor Joes"; System.out.println("Comparing '"+str1+"'"+" and '"+cs+"' : " + str1.contentEquals(cs)); System.out.println("Comparing '"+str2+"'"+" and '"+cs+"' :"+ str2.contentEquals(cs)); } }
Comparing 'Tutor Joes' and 'Tutor Joes' : true Comparing 'Computer Education' and 'Tutor Joes' :false
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions