This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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.