Java program to compare two string


import java.util.Scanner;

public class Comparestring

{

 public static void main(String[] args)

{

   String s1,s2;

   Scanner sc = new Scanner(System.in);

   System.out.println("ENTER THE STRING 1:");

   s1= sc.next();

   System.out.println("ENTER THE STRING 2");

   s2= sc.next();

   if(s1.equals(s2)) //if(s1.compareTo(s2)==0)

   {

       System.out.println("The Given Strings Are Equal");

   }

   else

        System.out.println("The Given Strings Are Not Equal");

    }

}


Comments

Popular Posts