This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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
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