This Java program checks whether two given strings have the same data (i.e., same characters in the same order).
public class Check_SameData { public static void main(String[] args) { String s1 = "Java Exercise"; String s2 = "Tutor joes"; String s3 = "Java Exercise"; boolean equ1 = s1.equals(s2); boolean equ2 = s1.equals(s3); System.out.println("'" + s1 + "' equals '" +s2 + "' ? " + equ1); System.out.println("'" + s1 + "' equals '" +s3 + "' ? " + equ2); } }
'Java Exercise' equals 'Tutor joes' ? false 'Java Exercise' equals 'Java Exercise' ? true
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions