public class EqualsExample
{
public static void main(String args[])
{
String s1="Gulzar";
String s2="Gulzar";
String s3="GULZAR";
String s4="Ludhiana";
System.out.println("The Strings Gulzar and Gulzar are same = " + s1.equals(s2));
//true because content and case is same
System.out.println("The Strings Gulzar and GULZAR are same = " + s1.equals(s3));
//false because case is not same
System.out.println("The Strings Gulzar and Ludhiana are same = " + s1.equals(s4));
//false because content is not same
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.