尝试调用方法getuserinput时出错。这是我的一些代码被破坏了。
initialvelocitybutton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
getuserinput(); //I am getting an error saying "The method getuserinput() is undefined for the type new ActionListener(){}"
}
});
static void getuserinput(){ //method to get users input
double initialvelocity = Double.parseDouble(
JOptionPane.showInputDialog("please enter initial velocity")); //gets initial value of intiial velcoity
double angleoflaunch = Double.parseDouble(
JOptionPane.showInputDialog("please enter angle of launch"));
}
答案 0 :(得分:3)
getuserInput()
被声明为static
。您必须使用类名称NameOfYourClass.getuserInput();