GeekInterview.com
Series: Subject: Topic:
Question: 11 of 1118

Compareto and equals method

Difference between CompareTo and equals method.
Asked by: cspatel | Member Since Jul-2012 | Asked on: Jul 3rd, 2012

View all questions by cspatel

Showing Answers 1 - 2 of 2 Answers
Sandhya.Kishan

Answered On : Jul 13th, 2012

View all answers by Sandhya.Kishan

CompareTo() method is derived from Comparable interface and is used to find the Ordering of Strings.
equals() method is from java.lang.Object and used for comparing objects.

  
Login to rate this answer.
Bharat

Answered On : Oct 1st, 2012

CompareTo method which is present in the String class is used to check the two strings. It checks each character with the other String and if found equals then returns 0. Else negative value or positive value based on which character is higher.

Equals method is used to check the values of the two string are equal then it returns true else false.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.