Home Java Java-get-example Java get Int from String
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java get Int from String

Advertisement
In this section, you will study how to obtain the integer value from String. For this, we have defined a string. The method Integer.parseInt(st) converts the string into the integer.

Java get Int from String

     

In this section, you will study how to obtain the integer value from String. For this, we have defined a string. The method  Integer.parseInt(st) converts the string into the integer.

Here is the code of GetIntFromString.java

public class GetIntFromString {

 public static void main(String[] args) {
  String st = "100";
  int i = Integer.parseInt(st);
  System.out.println("Integer value= "+i);
  }
}

Output will be displayed as

Download Source Code

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 6, 2008

Ask Questions?    Discuss: Java get Int from String  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Prateek Jain
November 18, 2012
if string is "123Hello"

if string is "123Hello" then how to extract 123 from it.
Prateek Jain
November 18, 2012
if string is "123Hello"

if string is "123Hello" then how to extract 123 from it.
poorna
February 10, 2014
java

if string is title if string is title then how to extract tile from it.
DMCA.com