Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Help Java S String to Int Conversion

Related Tutorials


 
 

Share on Google+Share on Google+

String to Int Conversion

Advertisement
This section illustrates you how to convert a string into its integer equivalent.

String to Int Conversion

     

This section illustrates you how to convert a string into its integer equivalent. To demonstrate the conversion of string into an integer we are taking an example that take string as input and converts it into its integer equivalent value.

The given example takes a string as input and then calls the parseInt() method of the Integer wrapper class to convert the string into the its integer equivalent and receives that integer value into a Intval variable and then displays that converted value on the console.

public class ConvertStringToInt {
  public static void main(String[] args) {
  String StrtoInt = "894";
  int Intval = Integer.parseInt(StrtoInt);
  
  System.out.println(Intval);
  }
}

 

Here is the Output of the program:

C:\>java StringToIntConversion
894
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



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 16, 2009

Related Tutorials

Discuss: String to Int Conversion  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com