- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert string to a number in Java
To convert a string to a number in Java, use the Integer.parseInt() method. First, let use create a String and set value.
String str = "45";
Now, take an Integer and use the Integer.parseInt() method.
Integer i = Integer.parseInt(str);
Let us see the complete example.
Example
public class Demo { public static void main( String args[] ) { String str = "45"; Integer i = Integer.parseInt(str); System.out.println("Num: " + i); } }
Output
Num: 45
- Related Articles
- Convert a String to a short number in Java
- Convert a String to a byte number in Java
- Convert a String to a double type number in Java
- Java Program to convert a String to a float type Number
- Convert bytes to a string in java
- Convert Java String to Short in Java
- How to convert a string to a number in Perl?
- Convert double to string in Java
- Convert short to String in Java
- Convert byte to String in Java
- Convert int to String in Java
- Convert String to Long in Java
- Convert IntStream to String in Java
- Convert String to IntStream in Java
- Convert String to Date in Java

Advertisements