suman negi


{ City } pune
< Country > india
* Profession * sr. java devloper
User No # 43621
Total Questions Posted # 0
Total Answers Posted # 1

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 4
Users Marked my Answers as Wrong # 0
Questions / { suman negi }
Questions Answers Category Views Company eMail




Answers / { suman negi }

Question { 6881 }

How do you compare two strings? any predefined method for
this?


Answer

You can compare the values of 2 Strings by following
methods of String class:-
Eg:- String a="abc"; String b="abc";
1> .equals() method it will return a boolean value.
eg:- if(a.equals(b)) will return true.
2> .compareTo() method.If the two java strings are exactly
the same, the compareTo method will return a value of 0
(zero).
eg:- if (a.compareTo(b) == 0){
// this line will print
System.out.println("a and b strings are the same.")
}

Is This Answer Correct ?    4 Yes 0 No