Java Programs to check if Strings are equal

Here is a simple java program to show whether the entered strings are equal or not….

class streq
public static void main(String args[]) throws IOException
System.out.println(“enter the first string”);
DataInputStream ds1 = new DataInputStream(;
String str1 = ds1.readLine();
System.out.println(“Enter the second string”);
DataInputStream ds2 = new DataInputStream(;
String str2 = ds2.readLine();
System.out.println(“the strings are equal”);
System.out.println(“the strings are not equal”);

Add Comment