String to Int Conversion

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


 
Ads

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

Share on Google+Share on Google+

String to Int Conversion

Posted on: November 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: String to Int Conversion  

Post your Comment


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

Ads

 

Ads