I am beginning to learn Java and I am stuck on how to receive the user's input as a String and converting it to an int afterwards so I can use If Statements. Thank you for reading guys, good programming for all.
Asked
Active
Viewed 608 times
-6
-
2``Integer.parseInt(inputString);``? – f1sh Apr 07 '16 at 22:13
-
You're going to get more useful help if you put more work into your question. We don't know what it is that you don't know, but if you show us what you've tried (code) then we can make some pretty accurate guesses and give you specific answers. – LinuxDisciple Apr 07 '16 at 22:15
-
I am sorry, it was my first question on the website and I eventually had to learn my lesson; I will be sure to use that method next time when in doubt, thank you. – L.Costa Apr 07 '16 at 23:42
1 Answers
0
Try this:
JOptionPane pane // your control
int result = Integer.parseInt(pane.getInputValue().toString());
System.out.println("result = " + result);

Andrej Istomin
- 2,527
- 2
- 15
- 22
-
Thank you for the help, I finally learned how to do it. Sorry if I was not clear enough. – L.Costa Apr 07 '16 at 23:41