Showing posts with label java equal string function. Show all posts
Showing posts with label java equal string function. Show all posts

Saturday, 15 June 2013

java stirng function equals()

import java.io.*;

public class equals
{
    public static void main(String []args)
    {
        String str,str1;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter first String ");
            str=cin.readLine();
            System.out.println("Enter another String ");
            str1=cin.readLine();
            if(str.equals(str1))
            {
                System.out.println(str+" &"+str1+" both string are equal ");
            }
            else
            {
                System.out.println(str+" &"+str1+" both string are not equal ");
            }
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}