Friday, June 8, 2012

Write a program to check whether two strings are equal or not. ?


♣♣♣ WRITE A PROGRAM TO CHECK WHETHER TWO STRINGS ARE EQUAL OR    
NOT. ♣♣♣                            

import java.io.*;
class pro1
{
            public static void main(String args[]) throws IOException
            {
            String s1,s2;
            InputStreamReader a=new InputStreamReader(System.in);
            BufferedReader b=new BufferedReader(a);
            System.out.print("Enter First string : ");
            s1=b.readLine();
            System.out.print("Enter Second string : ");
            s2=b.readLine();
                        if(s1.equals(s2))
                        System.out.print("Equal");
                        else
                        System.out.print("Not Equal");
            }
}



OUTPUT :-

            Enter first string : My Name is Kapil
            Enter Second string : My  Name  is Kamia
            Not Equal


            Enter first string : My Name is Kapil
            Enter Second string : My Name is Kapil
            Equal

No comments:

Post a Comment