Question: joptionpane how to use int?
Answer: You cannot cast a String to an int , but you can convert it using Integer. parseInt(string) . This because the input that the user inserts into the JOptionPane is a String and it is stored and returned as a String .