/*
* Here we will learn to convert String Object to byte primitives.
*/
public class ConvertStringTobytePrimitive {
public static void main(String[] args) {
String strObj = "100";
/**
* Constructs a newly allocated Byte object that represents the byte
* value indicated by the String parameter. The string is converted to a
* byte value in exactly the manner used by the parseByte method for
* radix 10.
*/
Byte byteObj = new Byte(strObj);
/*
* Byte class extends Number abstract class and overrides methods from
* Number class which returns the different type of primitives
* datatype().
*
* 1- byteValue() : Returns byte
* 2- shortValue() : Returns short
* 3- intValue() : Returns int
* 4- longValue() : Returns long
* 5- floatValue() : Returns float
* 6- doubleValue(): Returns double
*/
byte bytePrimitive = byteObj.byteValue();
System.out.println("Value of byte primitive :"+bytePrimitive);
}
}