Java 错误:参数列表长度不同
错误:Java 错误:参数列表长度不同,java,arrays,Java,Arrays,错误: private class ButtonSelect implements ActionListener { @Override public void actionPerformed(ActionEvent e) { Object Ps = e.getSource(); String selectedLanguage = (String) languageList.getSelectedItem(); JOptionPan
private class ButtonSelect implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
Object Ps = e.getSource();
String selectedLanguage = (String) languageList.getSelectedItem();
JOptionPane.showMessageDialog(StudentRecordsGUI.this,
"You selected the language: " + selectedLanguage);
if (selectedLanguage != "English") {
JOptionPane.showMessageDialog(StudentRecordsGUI.this,
"I'm sorry. The language you have selected is currently not available. Please try again.");
}
else
setVisible(false);
new Record (student, this, "Student Records");
}
} //end class ButtonSelect
我需要使用:
java:52: error: constructor Record in class StudentRecordsGUI.Record cannot be applied to given types;
new Record (student, this, "Student Records");
^
required: Student
found: ArrayList<Student>,StudentRecordsGUI.ButtonSelect,String
reason: actual and formal argument lists differ in length
从学生课堂上获取信息,但不需要。我如何编辑这一行,使它能够发布您的记录类?错误信息非常清楚。你至少试过阅读和理解它吗?还有一个你可能没有意识到的问题。因为在'else'子句中没有使用大括号,所以它只包含setVisible行。缩进的新记录。。。未在else子句中运行。这不会解决您在那里对构造函数的错误调用,但请将字符串与equals方法进行比较,而不是与==。否则你的if将永远不会评估为真。因此,在打了所有试图帮助你的人的耳光之后,你可以继续lakshman所说的:发布你的记录课程。但不管怎样:记录构造函数期望一个学生作为它的参数。把它交给那个学生,它就会起作用。
ArrayList<Student> student = new ArrayList<Student>();