Java Integer max() Method25 Mar 2025 | 2 min read The max() is a method of Integer class under Java.lang package. This method numerically returns the maximum value between the two method arguments specified by a user. This method can be overloaded and it takes the arguments in int, double, float and long. This method is specified by the Math Class. Note: If a positive and a negative number is passed as argument, it generated a positive result. And if, both the parameters passed as a negative number, it generates result with the lower magnitude.Syntax:Following is the declaration of max() method: Parameter:
Returns:The max() method returns the greater value between the two method arguments specified by a user. Exceptions:NA Compatibility Version:Java 1.5 and above Example 1Output: Math.max(5485,3242)=5485 Example 2Output: Enter the Two Numeric value: 45 77 Larger value of Math.max(45,77) = 77 Example 3Output: Result: -23 Example 4Output: Result: 23 Next TopicJava-integer-min-method |
Java method The compare() method is a method of Integer class under java.lang package. This method compares two integer values numerically. It returns the result in integer equivalent value by comparing the two int method arguments. The value returned is identical to what would be...
2 min read
Java Method The reverse() method of Java Integer class numerically returns the value obtained by reversing the order of the bits in the 2's complement binary representation of the specified integer value. Syntax: Following is the declaration of reverse() method: public static int reverse(int i) Parameter: DataType Parameter Description Required/Optional int i Integer value whose bits...
2 min read
Java Method The highestOneBit() method is a method of Integer class under java.lang package. This method returns int value with at most a single one-bit, in the position of the highest-order ("leftmost") one-bit in the specified int value. If the specified value has no one-bits...
2 min read
Java Method The numberOfTrailingZeros() method is a method of Integer class under java.lang package. This method returns the total number of zero bits following the lowest-order ("rightmost") one's-bit in the two's complement binary representation of the specified integer value i.e. it converts int value to...
2 min read
Java Method The shortValue() method of Java Integer class returns the value of this Integer as a short type after a primitive conversion. It overrides the shortValue() method of Number Class. Syntax: Following is the declaration of shortValue() method: public static int shortValue() Parameter: DataType Parameter Description NA NA This method does not take any...
2 min read
Java Method The min() is a method of Integer class under java.lang package. This method numerically returns the minimum value amongst the two method argument specified by a user. This method can be overloaded and it takes the arguments in int, double, float and long. Note:...
2 min read
Java Method The intValue() method is an instance method of Integer class under java.lang package. This method returns the value of the specified number as an int. It is inherited from the Number Class. Syntax: Following is the declaration of intValue() method: public int intValue() Parameter: DataType Parameter Description NA NA This method does not...
2 min read
Java Method The toBinaryString() method of Java Integer class returns a string representation of the integer argument as an unsigned integer in binary base 2. Note: If the argument is snegative, the unsigned integer value is the argument plus 232otherwise, it is equal to the argument....
2 min read
Java Integer.parseInt() Method The Java parseInt() method is a method of Integer class that belong to java.lang package. The parseInt() method in Java is crucial for converting string representations of numbers into actual integer values. This capability is fundamental in various programming scenarios, such as when...
10 min read
Java method The byteValue() is a method of byte class under java.lang package. It converts the given number into a primitive byte type and returns the value of integer object as byte. Also, it override the byteValue() method of Number class. Syntax Following is the declaration of...
2 min read
We request you to subscribe our newsletter for upcoming updates.
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