what is the difference between equals method and ==

Answer Posted / ramanareddy333

equal method compare the the content of the strings,where
as == compares the referance variables .
for example
string s1 = 'ramana'
string s2= ' ramana'
if(s1==s2)
s.o.p("s1, s2 are same");
else
s.o.p(" s1, s2 are not same");

ans = s1,s2 are not same because == compares the referance
variables.

Is This Answer Correct ?    6 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we have this () and super () together?

613


What is a nested structure?

541


Which sorting is used in arrays sort in java?

590


What is collections framework?

582


What are the various access specifiers in java?

570






Can you inherit from an abstract class java?

536


what do you mean by classloader in java?

577


write a program that list all permutations of ABCDEF in which A appears before B?

2015


What is java jit compilers?

562


How many times finalize method will be invoked? Who invokes finalize() method in java?

578


What is final keyword in java? Give an example.

579


Difference between abstract and concrete class ?

583


How can we create a thread in java?

589


How many characters is 2 bytes?

535


What is a functional interface?

549