What method is used to compare two strings ?

Answer Posted / interviewall

If string a="aaaa"; and String b="bbbb";
we can compare them as
if(a.equals(b)) and get a boolean as a return type.

////////////////////////////////////////////////////////

We can also compare String as
a.compareTo("aaaa"); which gives 0 as output as they are
equal.

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Name four container classes.

552


Difference between this() and super() ?

570


Can you call a method on a null object?

559


What is void in java?

585


Is array serializable java?

515






What is diamond operator in java?

493


Why do we need data structure in java?

572


What is ellipsis in java?

572


What is lazy programming?

559


What is the difference between JVM and JRE?

616


What are the 2 types of java programs?

558


Explain why wait(), notify() and notifyall() methods are in object class rather than in the reading class?

557


What do you mean by inner class in java?

562


What is a function in programming?

547


What is the benefit of using enum to declare a constant?

655