Pages

Monday 30 May 2011

// write a program in java to compare two strings whether equal or not.

0 comments
 

CODE


import java.lang.*;
import java.io.*;
public class CompString{
public static void main(String[] args) throws IOException{
System.out.println("String equals or not example!");
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter first string:");
String str1 = bf.readLine();
System.out.println("Please enter second string:");
String str2 = bf.readLine();
if (str1.equals(str2)){
System.out.println("The given string is equals");
}
else
{
System.out.println("The given string is not equals");
}
}
}

OUT[UT DISPLAY

Leave a Reply