This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
Hello, Welcome to JavaRanch. The short answer is: String string = "123"; int number = Integer.parseInt(string); or String string = "123.45"; double number = Double.parseDouble(string); If you'd like more information on the subject, I recommend doing a search on the beginner's forum. The link to the search page is at the top-right of this page. Good Luck.
Did you use String string = "123"; int number = Integer.parseInt(string); String string = "123.45"; double number = Double.parseDouble(string); in the same scope? Just use different variables and it should work fine. -anthony
Joined: Dec 10, 2001
Amir, If you are still having difficulties, it may be useful if you were to post the code you are trying to compile as well as the error messages you are receiving. Note: When posting code, please enclose it with the [ code ] and [ /code ] tags (click on the "CODE" button below the message posting textbox). Good Luck.