我得到以下Java編譯器錯誤:找不到符號
main.java:9: cannot find symbol
symbol : method parseInt(int)
location: class java.lang.Integer
int count = Integer.parseInt(getPennies());
^
main.java:23: incompatible types
found : java.lang.String
required: int
JOptionPane.showInputDialog("How many pennies do you have?");
^
2個錯誤
這裏是我的代碼
import javax.swing.*;
class main {
public static void main(String args[]) {
try {
int count = Integer.parseInt(getPennies());
System.out.println("You have "+count+" pennies");
} catch (NumberFormatException exception) {
System.out.println("Please insert a number");
getPennies();
}
}
public static int getPennies() {
int input =
JOptionPane.showInputDialog("How many pennies do you have?");
return input;
}
}
任何想法,爲什麼我收到這些錯誤?