This week's book giveaways are in the iOS and Features new in Java 8 forums. We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line! See this thread and this one 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.