what is the difference between equals method and ==

Answer Posted / subrahmanyam

== is userd to compare both are of same type
equals is used to compare both are of same contents


EX:
String s1="raju";
String s2=new String("raju");
if(s1.equals(s2))
System.out.println(" if(s1.equals(s2)"); //true
if(s1==s2)
System.out.println(" s1==s2"); //false

Is This Answer Correct ?    62 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a code to create a trigger to call a stored procedure

530


What is volatile data type?

549


What all access modifiers are allowed for top class ?

711


How do you convert an int to a string in java?

540


Can private class be extended java?

562






What initialize variables?

503


Can we sort set in java?

537


What are the new features in java 8?

568


Why is it called a string?

561


What are the topics in core java?

529


What is the intersection and union methods?

546


How many inner classes can a class have?

573


Explain how hashmap works?

588


What is string substring?

559


How can we find the actual size of an object on the heap?

802