Java Integer decode() method25 Mar 2025 | 2 min read The decode() method is a static method of Integer class under java.lang package. The main function of this method is to decode a string which is written in the form of (" ") into an integer value. The decode() method also accepts decimal, hexadecimal, and octal numbers. It is given by the following grammar: DecodableString:Signopt DecimalNumeral Signopt 0x HexDigits Signopt 0X HexDigits Signopt # HexDigits Signopt 0 OctalDigits Sign:This type of String will throw a NumberFormatException or represent a positive value. The result is negated if sign of the first character of the decodable String is minus. There are no whitespace characters are permitted in the String. SyntaxFollowing is the declaration of decode() method: Parameter:
Returns:The decode() method returns an Integer object which hold the int value represented by String nm. Exceptions:NumberFormatException - This method throws an exception if the String does not contain an integer which can be parsed. Compatibility Version:Java 1.2 and above Example 1Output: 81 276 -260 Example 2Output: Integer Number is = 555 Example 3This is an example in which we pass the String value and it shows NumberFormatException. Output: Exception in thread "main"java.lang.NumberFormatException: For input string: "JavaTpoint" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.valueOf(Integer.java:740) at java.lang.Integer.decode(Integer.java:1197) at myPackage.DecodeMethodExample.main(DecodeMethodExample.java:8) Example 4Output: Enter a value to decode: 656 Result:656 Next TopicJava-integer-divideunsigned-method |
Java method The compareTo() method is a method of Integer class under java.lang package. This method compares two integer objects numerically. It returns the result of the value 0 if Integer is equal to the argument Integer, a value less than 0 if Integer is...
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 parseUnsignedInt() is a method of Java Integer class. There are three different types of parseUnsignedInt() method which can be differentiated depending on its parameter. These are: Java Integer parseUnsignedInt (String s) Method Java Integer parseUnsignedInt (String s, int radix) Method Java Integer parseUnsignedInt (CharSequence s, int...
5 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 remainderUnsigned() method is a method of Java Integer class which returns the unsigned remainder of dividing the first argument by the second argument where each argument and the result is interpreted as an unsigned value. Syntax: Following is the declaration of remainderUnsigned() method: public static...
2 min read
Java Method The rotateRight() method of Java Integer class returns the value obtained by rotating the two's complement binary representation of the specified int value right by the specified number of bits. (Bits shifted out of the right hand, or low-order). Bit shifting is a bitwise...
3 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 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 toHexString() method of Java Integer class returns a string representation of the integer argument as an unsigned integer in hexadecimal base 16. The following characters are used as hexadecimal digits: 0 1 2 3 4 5 6 7 8 9 a b c d...
2 min read
Java Method 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....
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