How can I use JOPTION PANE to have a user input an integer and then have it printed on the screen? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I use JOPTION PANE to have a user input an integer and then have it printed on the screen?

JOptionPane

20th Feb 2017, 12:51 AM
Terrence Donerson
Terrence Donerson - avatar
3 Answers
+ 1
Use the showInputDialog() method of JOptionPane for that.
20th Feb 2017, 1:09 AM
DaemonThread
DaemonThread - avatar
+ 1
if you mean how to convert string from user to get the integer value from it it can done like that String s ="12"; int x = Integer.parseInt( s ); that way it converted it from string to integr and could do operations on it
20th Feb 2017, 2:36 AM
ahmed khattab
ahmed khattab - avatar
+ 1
Thank You Ahmed!
20th Feb 2017, 2:37 AM
Terrence Donerson
Terrence Donerson - avatar