What are the return values of compareTo in Java?

Asked

Viewed 243 times

0

What is the difference between the 0, 1 and -1 returns of compareTo() in Java?

Example:

Date date1 = '08/02/2019';
Date date2 = '08/03/2019';

date1.compareTo(date2);
  • The difference is 0:date1 == date2 , 1:date1 > date2, -1:date1 < date2

  • Thank you very much.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.