Java Double compare() MethodThe compare() method of Java Double class compares two specified double values. SyntaxParametersTwo parameters- d1- The first double to be compared. d2- The second double to be compared. Return valueThis method will return value -
Example 1Test it NowOutput: 10.56 is greater. Difference is= 0.5600000000000005. Example 2Test it NowOutput: Error:(13, 26) java: method compare in class java.lang.Double cannot be applied to given types; required: double,double found: java.lang.Double reason: actual and formal argument lists differ in length Example 3Test it NowOutput: Enter your Family income 45000 Sorry, You are not eligible for the subsidy
Next TopicJava Double
|