adspace


How does compareto work in java?

Answer Posted / Kailash Chandra Singh

The `compareTo()` method is used by Comparable interface to compare two objects. It returns 0 if the objects are equal, a negative number if the current object comes before the passed object, and a positive number if it comes after.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to find the whether a number is an Armstrong number or not?

1096


What do you mean by an interface in java?

1101


Is minecraft 1.15 out?

1045


explain different ways of using thread? : Java thread

1080


What are the differences between heap and stack memory in java?

1136


What is the difference between equals() and == in java?

1038


What is the difference between break and continue statements?

1124


What is parsing in java?

1039


What is java string pool?

1080


How to create a base64 decoder in java8?

1136


What is an object in java and how is it created?

1139


Realized?

2260


What is a constructor overloading in java?

1124


How to sort array in descending order in java?

994


Explain public static void main(string args[]) in java.

1074