Java Integer.decode(String nm)

Syntax

Integer.decode(String nm) has the following syntax.

public static Integer decode(String nm)   throws NumberFormatException

Example

In the following code shows how to use Integer.decode(String nm) method.


public class Main {
  public static void main(String[] args) {
/*  w w w  .ja v a2 s.com*/
    System.out.println(Integer.decode("010"));// octal numbers
    System.out.println(Integer.decode("0XA"));// hexadecimal numbers
    System.out.println(Integer.decode("-0XA"));// minus hexadecimal numbers
    System.out.println(Integer.decode("-#A"));// minus hexadecimal numbers
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable