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
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 5 of 870    Print  
What is the difference between == & .equals

  
Total Answers and Comments: 9 Last Update: June 14, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 11, 2005 06:13:39   #1  
Jitendra Desale        

RE: What is the difference between == & .equals
== used for comparing two Strings Objects rather than value. 
 
.equels is used for comparing two strings

 
Is this answer useful? Yes | No
August 18, 2005 05:21:39   #2  
santoshini        

RE: What is the difference between == & .equals
== is equals is used for checking the equality of values of all datatypes, 
.equals is used for checking the equaliy of strings.

 
Is this answer useful? Yes | No
September 12, 2005 07:15:46   #3  
D.S.Reddy        

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

== is used to check whether the references of the both are equal or not?

.equals() is used to the compare the values in that references.


 
Is this answer useful? Yes | No
September 15, 2005 08:14:01   #4  
Archana Member Since: September 2005   Contribution: 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

}


 
Is this answer useful? Yes | No
September 27, 2005 05:37:55   #5  
Praveen Kumar        

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

1.    == is swallo comparison. Means it will use the memory location for comparison rather that the data.

2. .equals() is indepth comparison. I will check the content between two object rather that the memory location.


 
Is this answer useful? Yes | No
September 27, 2005 06:06:07   #6  
Vinay Kumar        

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

== is used for checking the datatypes values like int,float,double..

.equals is used to check the Objects like String,Vector ....


 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
October 03, 2005 02:50:41   #7  
mehar        

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

The difference between ==  and .equals is

String a="john",b="joi";

if (a.equals(b))// it compares internaly for the same materials

if(a==b)// it compares for the memory location


 
Is this answer useful? Yes | No
May 20, 2008 07:05:57   #8  
udays Member Since: May 2008   Contribution: 1    

RE: What is the difference between == & .equals
.equals -> Compares chracters between two strings are equal.
==        -> Compares  object reference between two strings are same .
 
--Khushi

 
Is this answer useful? Yes | No
June 14, 2008 10:57:26   #9  
amit23347 Member Since: June 2008   Contribution: 1    

RE: What is the difference between == & .equals
In case of .equals,the contents of the objects are compared.
in case of ==,the data types of objects are compared.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape