Tuesday, September 2, 2008
Comparing Two Strings Using equals()
import java.lang.*;
import java.io.*;
public class equalstrings{
public static void main(String[] args) throws IOException{
System.out.println("String Compares Example Using Equals() Method");
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter First String:");
String str1 = bf.readLine();
System.out.println("Enter Second String to Compare :");
String str2 = bf.readLine();
if (str1.equals(str2)){
System.out.println("Both the Strings are Equal!");
}
else{
System.out.println("Both the Strings are not Equal!");
}
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment