Search

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

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


Share this article :
 

Post a Comment

 
Support : everytricks4.blogspot.in/ | Johny Template | Mas Template
Copyright © 2011. Computer Tricks - All Rights Reserved
Creating Website Published by
Proudly powered by Blogger