0
static void sort (Textbook [ ] info, int numEntries)
{
    long tempIsbn = 0;
    String tempTitle = "";
    String tempAuthor = "";

    for (int i = 0; i < numEntries; i++) //sorts the array
    {
        int minPos = i;
        for (int j = i + 1; j < numEntries; j++)
        {
            if ( info [minPos].getIsbn() > info [j].getIsbn())
            {
                minPos = j;
            } //end if
            if (i < minPos)
            {
                tempIsbn = info [i].getIsbn();
                info [i].getIsbn() = info [minPos].getIsbn();
                info [minPos].getIsbn() = tempIsbn;

                tempTitle = info [i].getTitle();
                info [i].getTitle() = info [minPos].getTitle();
                info [minPos].getTitle() = tempTitle;

                tempAuthor = info [i].getAuthor();
                info [i].getAuthor() = info [minPos].getAuthor();
                info [minPos].getAuthor() = tempAuthor;

            } //end if

        } //end for
    } //end for
} //end sort

データベースをソートしようとしていますが、最初の値を 2 番目の値と比較しようとするとエラーが発生します。私が理解していることinfo [i].getAuthor();から、オブジェクトクラスへの呼び出しですが、値を返すべきではありませんか? なぜこれらのエラーが発生するのか疑問に思っていると思いますが、2つの数値を比較する必要がありますか?

これは私のオブジェクト クラスのコードです。

    public long getIsbn ( )
{
            return this.isbn;
}

    public String getTitle ( )
{
    return this.title;
}

public String getAuthor ( )
{
    return this.author;
}

これらは、私が得ているエラーの一部です。

    TextbookTracker.java:156: unexpected type
    required: variable
    found   : value
        info [i].getIsbn() = Long.parseLong (isbnInput);
                        ^
    TextbookTracker.java:161: unexpected type
    required: variable
    found   : value
        info [i].getTitle() = titleInput;
                         ^
    TextbookTracker.java:166: unexpected type
    required: variable
    found   : value
        info [i].getAuthor() = authorInput;
                          ^
    TextbookTracker.java:264: unexpected type
    required: variable
    found   : value
                info [i].getIsbn() = info [minPos].getIsbn();
                                ^
    TextbookTracker.java:265: unexpected type
    required: variable
    found   : value
                info [minPos].getIsbn() = tempIsbn;
                                     ^
    TextbookTracker.java:268: unexpected type
    required: variable
    found   : value
                info [i].getTitle() = info [minPos].getTitle();
                                 ^
    TextbookTracker.java:269: unexpected type
    required: variable
    found   : value
                info [minPos].getTitle() = tempTitle;
                                      ^
    TextbookTracker.java:272: unexpected type
    required: variable
    found   : value
                info [i].getAuthor() = info [minPos].getAuthor();
                                  ^
    TextbookTracker.java:273: unexpected type
    required: variable
    found   : value
                info [minPos].getAuthor() = tempAuthor;
                                       ^
    9 errors
4

1 に答える 1

2
 TextbookTracker.java:156: unexpected type
 required: variable
 found   : value
    info [i].getIsbn() = Long.parseLong (isbnInput);

値に値をどのように割り当てることができますか? 代入演算子の左側には変数が必要ですが、ここでは値を返すメソッド呼び出しです

于 2013-05-10T04:46:10.823 に答える