java中书籍数组的问题
我在两种方法中有错误,java中书籍数组的问题,java,Java,我在两种方法中有错误,public int getBookIndex和public boolean updateTitle /d/1r4XAhOC0VvWfaxnPZUFyiSGdk2gpFs2mZoTkJ6CJnGk/编辑?usp=共享 公共类库{ 私有字符串[]标题; 私人网页; 私家侦探; 私有字符串[]作者; 公共图书馆(国际图书总数){ nb=总图书数量; 标题=新字符串[nb]; nbPages=新整数[nb]; 作者=新字符串[nb]; } 公共无效设置日期(字符串tit、int
public int getBookIndex
和public boolean updateTitle
/d/1r4XAhOC0VvWfaxnPZUFyiSGdk2gpFs2mZoTkJ6CJnGk/编辑?usp=共享
公共类库{
私有字符串[]标题;
私人网页;
私家侦探;
私有字符串[]作者;
公共图书馆(国际图书总数){
nb=总图书数量;
标题=新字符串[nb];
nbPages=新整数[nb];
作者=新字符串[nb];
}
公共无效设置日期(字符串tit、int nbP、字符串au){
对于(intx=0;x删除break语句(您的else条件也是错误的)-如下所示
public int getBookIndex(String find_tit) {
for (int x = 0; x < nb; x++) { // not sure, but probably not <=
if (titles[x].equals(find_tit)) { // not ==
return x; // probably not x+1.
}
}
return (-1);
}
public boolean updateTitle(String old_titl,
String new_titl) {
for (int x = 0; x < nb; x++) { // not sure, but probably not <=
if (titles[x].equals(old_titl)) { // not ==
titles[x] = new_titl;
return true;
}
}
return false;
}
public int getBookIndex(字符串find_tit){
对于(int x=0;xpublic int getBookIndex(String find_tit) {
for (int x = 0; x < nb; x++) { // not sure, but probably not <=
if (titles[x].equals(find_tit)) { // not ==
return x; // probably not x+1.
}
}
return (-1);
}
public boolean updateTitle(String old_titl,
String new_titl) {
for (int x = 0; x < nb; x++) { // not sure, but probably not <=
if (titles[x].equals(old_titl)) { // not ==
titles[x] = new_titl;
return true;
}
}
return false;
}