How to convert integer to string and string to integer?
Mindy Wu
Ranch Hand
Joined: Jan 12, 2001
Posts: 121
posted
0
I know a method to convert string to interger: for example: String strNum = "123"; int intNum = Integer.parseInt(strNum); Is there are any other way to do the same thing?? By the way, how to use toString(); when should I include argument in the () and don't. Mindy Wu
Art Metzer
Ranch Hand
Joined: Oct 31, 2000
Posts: 241
posted
0
Hi, Mindy. If you decide to go with your code, remember that parseInt() throws a NumberFormatException. You could also use
To convert an int to a String, use any one of the following:
(This information from the Java FAQ.) And, to my knowledge, the toString() method never takes any arguments. To use it, just call it from whatever object you'd like to see in string form: Integer.toString(), Object.toString(), etc. The resultant object will of course be a String. Hope this helps, Mindy. Art
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
posted
0
You may want to look up the intValue() method. To convert in int to a string object, You can just wrap your in value using the Integer() method. Bosun
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Mindy Wu
Ranch Hand
Joined: Jan 12, 2001
Posts: 121
posted
0
Thank you all! That's really help me out!
Happy programmer! Mindy
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How to convert integer to string and string to integer?