Monday, 6 November 2017

java methods



Question 30
What is equals()
 Ans
It compare two strings and it is case sensitive
Question 31
What is equalsIgnoreCase()
 Ans
This function compare two strings but it is not case sensitive.
Question 32
Give example of equals()
 Ans
String s1="this4is4my4book";
String s2="this4is4my4book";
String s3="lkajfslagj;fklgja";
System.out.println(s1.equals(s2));  //true
 System.out.println(s3.equals(s2));  //false
Question 33
Give example of equalsIgnoreCase()
 Ans
String s1="thIs4is4My4book";
String s2="This4is4my4Book";
String s3="lkajfslagj;fklgja";
System.out.println(s1.equalsIgnoreCase(s2));  //true
 System.out.println(s3.equals(s2));               // false

No comments:

Post a Comment