Javatpoint Logo
Javatpoint Logo

Java Double.compareTo() Method

The compareTo() method of Double class compares two double values numerically.

Syntax

Parameters

anotherDouble - the Double value to be compared

Return value

This method returns the value-

  • Zero, if anotherDouble has same value as this Double.
  • Positive value, if anotherDouble has a greater value than that of this Double.
  • Negative value, if anotherDouble has less value than that of this Double.

Example 1

Test it Now

Output:

10.44 is greater.
Answer after subtraction is= 0.4399999999999995

Example 2

Test it Now

Output:

Enter your percentage
48
Congrats you are eligible for the Exam.

Next TopicJava Double





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA