GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Tech FAQs  >  Programming  >  Java

 Print  |  
Question:   What is the difference between == & .equals



September 09, 2005 08:14:01 #4
 Archana J2EE Expert  Member Since: September 2005    Total Comments: 3 

RE: What is the difference between == & .equals
 

== is used to compare the number type data types viz. int, float,double  and also the boolean datatypes.

e.g. int x=10;

if(x==10)

{

// your code

}

boolean flag = true;

if(flag==false)

{

// Action1

}

if(flag==ture)

{

//Action2

}

.equals() method is used to compare the String data types

viz.

String str = "Hello";

if(str.equals("Hello"))

{

// Your code of action

}

     

 

Back To Question