Java Data Type Tutorial - Java Short.decode(String nm)








Syntax

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

public static Short decode(String nm)   throws NumberFormatException

Example

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

public class Main {
  public static void main(String[] args) {
    //from  w  ww .  j  a  v  a 2 s .co m
    System.out.println("Decimal 10:"+Short.decode("10"));
    System.out.println("Octal 10:"+Short.decode("010"));
    System.out.println("Hex F:"+Short.decode("0XF"));
    
    
    System.out.println("Negative Hex F:"+Short.decode("-0XF"));
  }
}

The output: