Java Byte.decode(String nm)

Syntax

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

public static Byte decode(String nm)   throws NumberFormatException

Example

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

The following code use decode method from Byte class to do the decoding for strings which represents the byte values


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

The output:





















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