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

What is java and its types?

547


What Is Composition?

575


Can a top level class be private or protected?

570


How does thread synchronization occurs inside a monitor?

542


Explain about map interface in java?

583






What are parsing rules?

495


What are the advantages and disadvantages of reference counting in garbage collection?

569


What is the difference between the ">>" and " >>>" operators in java?

503


How you can force the garbage collection?

533


How do you escape json?

536


What is == and === in javascript?

553


Is static a keyword in java?

519


What is your platform’s default character encoding?

551


Can You Have Virtual Functions In Java?

581


What is the difference between an if statement and a switch statement?

642