String To Primitive Data conversions  | Core Java Tutorials

This Core Java Tutorials “String To Primitive Data Conversion” post explains clearly how to convert String object into primitive byte and why parseByte() method throwing Exception.


String to byte :

  • This program explains how to convert String to byte.
  • Anything we represents with double quotes is called String object.
  • Following pre-defined java.lang.Byte class method used to perform this conversion.


Conversion Program:


Why parseByte() method throws Exception?

  • parseByte() converts String to byte.
  • It can parse(converts) only if String value is with in the range of byte(-128 to +127)
  • Data conversions will be done at run time.
  • Invalid input string to convert results Run time Error.
  • In java Run time Error is called Exception.


Share this