All In One Script



PHP,HTLM,CSS,Jquery,AJAX,Javascript and etc doubts and sample codes

  • Home
  • Javascript
  • PHP
  • CSS
  • SQL/MYSQL

How to convert a String to an int in Java?

by Blogger 4:35:00 AM data-type-conversion int java string type-conversion

How to convert a String to an int in Java?

How can I convert a String to an int in Java?
My String contains only numbers and I want to return the number it represents.
For example, given the string "1234" the result should be the number 1234.


Solution:

int foo = Integer.parseInt("1234");
See the Java Documentation for more information.
(If you have it in a StringBuilder (or the ancient StringBuffer), you'll need to do Integer.parseInt(myBuilderOrBuffer.toString()); instead).

http://stackoverflow.com/questions/5585779/how-to-convert-a-string-to-an-int-in-java








READ MORE
SHARE :

Search This Blog

Followers

  • Popular
  • Recent
  • Comments

Instagram

About

Popular Posts

statcounter



statcounter



Template Created By ThemeXpose & Blogger Templates