Convert String to numeric data type in Java

To convert String data type to numeric data type we can use wrapper classes of numeric primitives.

We convert similarly for other numeric data types by using their wrapper class versions.

If we try to convert a string that is not a number(the content of the string is not a number), we will get NumberFormatException which is a runtime exception.

Converting numeric data type into String data type is quite easy.

The String is a special class and everything that concatenates with string will become a string. So the easiest way is to just concatenate.

Another way is using valueOf method of String to convert numeric data to String.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store