gpt4 book ai didi

java - 必需 : variable, 找到值 - 对数据库进行排序

转载 作者:行者123 更新时间:2023-12-02 07:02:22 28 4
gpt4 key购买 nike

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

我正在尝试对数据库进行排序,但当我尝试将第一个值与第二个值进行比较时出现错误。据我了解, info [i].getAuthor(); 是对对象类的调用,但它不应该返回一个值吗?我想我想知道为什么我会收到这些错误,因为它应该比较两个数字?

这是我的对象类的代码。

    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

最佳答案

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

如何将一个值赋给一个值?赋值运算符的左边是一个变量,而这里是一个返回值的方法调用

关于java - 必需 : variable, 找到值 - 对数据库进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16475278/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com