Home > Java > Javagetting Started > body text

How to convert string to number in java

王林
Release: 2020-10-20 11:09:08
Original
10967 people have browsed it

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.

How to convert string to number in java

Conversion between string and int

(Recommended tutorial: java course)

Convert string to int:

Integer.valueOf("12")
Copy after login

Convert int to string:

String.valueOf(12)
Copy after login

Conversion between char and int

First convert char to string

String str=String.valueOf('2')
Copy after login
Integer.valueof(str)
Copy after login

Or

Integer.PaseInt(str)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!