Home >Java >Javagetting Started >How to convert string to number in java
Java method to convert string to number: [Integer.valueOf("12")]. If you want to convert numbers to strings, you can use the [String.valueOf(12)] method.
Conversion between string and int
(Recommended tutorial: java course)
Convert string to int:
Integer.valueOf("12")
Convert int to string:
String.valueOf(12)
Conversion between char and int
First convert char to string
String str=String.valueOf('2')
Integer.valueof(str)
Or
Integer.PaseInt(str)
Integer.valueof returns an Integer object, and Integer.paseInt returns an int
Related recommendations: Java Getting Started
The above is the detailed content of How to convert string to number in java. For more information, please follow other related articles on the PHP Chinese website!