whats the difference between == and .equal ?

Answer Posted / james rajesh

One database tale contain id and name...mostly id's are in int and name's are in String...if u want to compare with id and one number means u use ==
like, if(id==1)
if u want to compare name means u use .equals
like, if(name.equals("Bangalore"))
So point of view,
== used to compare integer
.equals used to compare String

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What the difference is between execute, execute Query, execute Update?

375


What is the difference between length and length () in java?

527


Can we have two main methods in a java class?

540


What is passing by reference in java?

543


What is difference between printf and scanf?

523






What is the main advantage of passing argument by reference?

505


How will you serialize a singleton class without violating singleton pattern?

1524


How do I stop concurrentmodificationexception?

513


What is the difference between an argument and a parameter?

541


What is a java applet? What is an interface?

635


What is qms certification?

522


Is it correct to say that due to garbage collection feature in java, a java program never goes out of memory?

578


What is the difference between menuitem and checkboxmenu item?

784


How can we make a class singleton?

578


Are arrays static in java?

588