File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
string to integer conversion
Joined: Oct 21, 2004
Oct 22, 2004 13:18:00
I need to change
"7777" to integer 7777, and integer 15 to string "15".
I would appreciate if you can help.
Thanks in advance,
Joined: Feb 24, 2004
Oct 22, 2004 13:58:00
Well, the answer to both of your questions can be found in the Javadocs for the
rahul V kumar
Joined: May 20, 2003
Oct 22, 2004 14:00:00
You have posted the same question in your other thread.
It would be easy to follow if you post at only one place.
You should get your answers here
String to int
int i = Integer.parseInt("7777");
you can have it in a try catch block or check to make sure that the string is indeed a valid number.
Joined: Sep 14, 2001
Oct 23, 2004 00:34:00
You can convert int to String using Integer.
String strValue = "7777"; int intValue = Integer.parseInt(strValue); int intValue2 = new Integer(strValue).intValue();
Remember, those will throw
if the string doesn't contain a valid value.
And about convert int to String you can use String.
int intValue = 15; String strVal1 = String.valueOf(intValue);
Oh ya... now in J2SE 5.0, there is a new feature about convert between primitive data type and its wrapper class. It is Autoboxing/unboxing.
You can read at
Hope this help...
Correct me if I am wrong..
I agree. Here's the link:
subject: string to integer conversion
Buffered Readers and hashtables.
how to add numbers in string
Type conflict while saving XML
How to iterate multiple list in an object?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014