Java BigInteger compareTo() methodThe compareTo() method of Java BigIntegerclass is used to compare two BigIntegervalues.This method is provided in preference to individual methods for each of the six boolean comparison operators (<, == ,> ,>=, !=, <=). This method computes (x.compareTo(y) <op> 0) , where <op> is one of the six comparison operators. Syntax:Parameter:val-BigInteger to which this BigInteger is to be compared Returns:This method returns -1, 0 or 1 as this BigInteger is numerically less than, equal to, or greater than val. Note: This method is specified by compareTo in interfaceComparable <BigInteger>.ExampleTest it NowOutput: First value is greater. Next TopicJava BigInteger |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India