-1

これは私のエラーです。このエラーが発生する理由を知っている人はいますか? JGraspを使用しています

PeerTutorReport.java:13: error: <identifier> expected
    public static String[] getTutorNames(listNames) {
                                                  ^
1 error

----jGRASP wedge2: プロセスの終了コードは 1 です。

import javax.swing.JOptionPane;
import java.util.Arrays;


public class Report {

public static void main(String[] args) {


      String[] listNames = getTutorNames();
}

public static String[] getTutorNames(listNames) {

      String firstName;
    String lastName;
    String[] listNames = new String[10];

    for (int x = 0; x < listNames.length; x++) {
        firstName = JOptionPane.showInputDialog(null, "Enter Tutor's First Name: ");
        lastName = JOptionPane.showInputDialog(null, "Enter Tutor's Last Name: ");

        if (firstName.equals("") && lastName.equals("")) {
            break; // loop end
        }
        listNames[x] = lastName + ", " + firstName;
    }
    return listNames;
}

}

4

4 に答える 4

0

Stringメソッドの署名は、メソッドに欠落していたパラメーターに注意してください。

public static String[] getTutorNames(String listNames)

また、メソッドの呼び出し中に文字列を渡す必要があります。お気に入り

String[] listNames = getTutorNames("someName");

または

パラメータを取らないメソッドを以下のように変更します

public static String[] getTutorNames()
于 2013-04-05T05:06:56.940 に答える
0

このメソッドに引数を渡すべきではありませんか。

 getTutorNames(someArg); //This is how you'd call the `getTutorNames(String[] listNames)` method.

また、これは次のようにする必要があります:-

public static String[] getTutorNames(String[] listNames){ // Give a type for the "listNames" argument

また、ここの引数に別の名前を付けるか、メソッドに別の名前を付ける必要がありgetTutorNames(String[] listNames)ます。String[] listNames = new String[10];getTutorNames

更新:-以下のコードは機能します。本人確認済み。

public static void main(String[] args) {

    String[] listNames = getTutorNames();
}

public static String[] getTutorNames() {
    ...
}
于 2013-04-05T05:01:38.010 に答える