Friday, April 5, 2019

equals() in java

equals() in java                                                                            edited by diya


import java.util.Scanner;
class p19
{
public static void main(String args[])
{
Scanner n=new Scanner(System.in);

System.out.println("Enter a string");
String s1=n.nextLine();
System.out.println("Enter a string");
String s2=n.nextLine();
System.out.println(s1.equals(s2));
}

}


D:\>javac p19.java

D:\>java p19
Enter a string
diya
Enter a string
diya
true

D:\>java p19
Enter a string
dil
Enter a string
diya
false

D:\>

No comments:

Post a Comment