Please can anyone tell me how to convert a string in a text field to an integer. im using
[ String q = answerField.getText();
int n1 = Integer.parseInt(q);]
in my programme but i get the errors:
Exception in thread "main" java.lang.NumberFormatException: For input string: "Enter Answer here!"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:497)
at BackgroundImage.<init>(BackgroundImage.java:72)
at BackgroundImage.main(BackgroundImage.java:15)
can anyone help please?