Byte decode(String nm)
decodes a String into a Byte.
decode
has the following syntax.
public static Byte decode(String nm) throws NumberFormatException
decode
has the following parameters.
decode
returns
a Byte object holding the byte value represented by String
decode
throws.
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.j a v a 2 s .c o 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: