Java Integer equals() Method25 Mar 2025 | 2 min read The equals() method is a method of Integer class under java.lang package. This method compares the value of the parameter to the value of the current Integer object. It returns Boolean (True or False) which corresponds to the equality of this Integer and method argument object. It also overrides the equals() method of Object class. Syntax:Following is the declaration of equals() method: Parameter:
Returns:The equals() method will return true if the argument is not null and if the integer objects are the same as method argument object, otherwise it will return false. Exceptions:InputMismatchException Compatibility Version:Java 1.2 and above Example 1Output: obj1 and obj2 are equal. True or False? = false obj1 and obj2 are equal. True or false? = true Example 2Output: 1. Input the first Integer Number to be Compare: 34 Input the second Integer Number to be Compare: 34 Both the Integer numbers are same... 2. Input the first Integer Number to be Compare: 45 Input the second Integer Number to be Compare: 87 Both the Integer numbers are different... Example 3Output: objA == objB? true objB == objC? false objA == objC? false objC == objA? false objB == objA? true Example 4Output: ObjFloat == ObjDouble? false Next TopicJava-integer-floatvalue-method |
Java Method The rotateLeft() method of Java Integer class returns the value obtained by rotating the two's complement binary representation of the specified int value left by the specified number of bits. (Bits shifted out of the left hand, or high-order). Bit shifting is a bitwise...
3 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
Java Method The hashCode() method is a Java Integer class method which returns the hash code for the given inputs. There are two different types of Java hashCode() method which can be differentiated depending on its parameter. These are: Java Method Java Integer hashCode(int value) Method hashCode()...
3 min read
Java Method The sum() method of Java Integer class numerically returns the sum of its arguments specified by a user. This method adds two integers together as per the + operator. It can be overloaded and accepts the arguments in int, double, float and long. Note:...
2 min read
Java Method The signum() method of Java Integer class returns the signum function of the specified int value in the method argument. The signum function can be computed as: -1, if the specified number is negative. 0, if the specified number is zero. 1, if the specified number...
2 min read
Java Method The longValue() method is an instance method of Long class under java.lang package. This method returns the value of the specified long object as long equivalent. The longValue() method were inherited from the Number Class. Syntax: Following is the declaration of longValue() method: public int longValue() Parameter: DataType Parameter Description NA NA This...
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 Method The toOctalString() method of Integer class returns a string representation of the integer argument as an unsigned integer in octal base 8. The following characters are used as octal digits: 0 1 2 3 4 5 6 7 Note: If the argument is negative, the unsigned...
2 min read
The Java Integer class comes under the Java.lang.Number package. This class wraps a value of the primitive type int in an object. An object of Integer class contains a single field of type int value. Java Integer Methods The Java Integer class provides several methods for converting...
3 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
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