当前位置: 代码迷 >> Java相关 >> 帮忙看看程序中的异常如何修改~
  详细解决方案

帮忙看看程序中的异常如何修改~

热度:200   发布时间:2016-04-22 21:36:09.0
帮忙看看程序中的错误怎么修改~~~~
class BookManage
{
   int max=5;
   Book[] booklist;
   int i,j;
   String note;
   public void BookManage()
   {
      booklist=new Book[max];
      i=-1;
      j=0;
   }
   public void addBook(String isbn,String bname,String bauthor,String bpulisher,double bprice)
   {
      i++;
      if(i>=max)
         note="存书量超过预定值,不能再添加了!";
      else
      {
         booklist[i]=new Book(isbn,bname,bauthor,boublisher,bprice);
         j=1;
      }
   }
   public void searchBook(String bookname)
   {
      for(j=0;j<i;j++)
      {
         if(booklist[j].getBookName().equals(bookName))
         {
             note=this.toString();
             break;
         }
         else
            note="\n没有查到所要的书。";
      }
   }
   public String toString()
   {
      note="\n书的信息:"+booklist[j].getISBN()
            +"|"+booklist[j].getBookName()+"|"+booklist[j].getAuthor()
            +"|"+booklist[j].getPublisher()+"|"+booklist[j].getPrice();
      return note;
   }
}
public class testExample2_4
{
     public static void main(String args[])
     {
          System.out.println("例2—4操作情况如下:");
          BookManage bm=new BookManage();
          bm.addBook("978-7-6666","Java上机练习","真老师","高等教育",20);
          System.out.println(bm.toString());
          bm.addBook("978-7-9999","数据结构","真老师","南京大学",28);
          System.out.println(bm.toString());
          bm.addBook("978-7-8888","面向对象程序设计","施珺","清华大学",32);
          System.out.println(bm.toString());
          bm.addBook("7-113-07777","VB学习与考试指导","施珺","中国铁道",35);
          System.out.println(bm.toString());
          bm.addBook("7-113-06658","VFP二级考前指导第一版","施珺","中国铁道",22);
          System.out.println(bm.toString());
          bm.addBook("7-113-08888","VFP二级考前指导第二版","施珺","中国铁道",29);
          System.out.println(bm.note);
          System.out.println("\n计数情况:i="+bm.i+"j="+bm.j);
          bm.searchBook("VFP二级考前指导");
  System.out.println("\nsearchBook("VFP二级考前指导")--"+bm.note);
  bm.searchBook("数据结构");
          System.out.println("\nsearchBook("数据结构")--"+bm.note+"\n");
     }
}




错误提示为:
C:\Users\xuqianqian\Desktop\testExample2_4.java:67: 需要 ')'
  System.out.println("\nsearchBook("VFP二级考前指导")--"+bm.note);
                                    ^
C:\Users\xuqianqian\Desktop\testExample2_4.java:67: 不是语句
  System.out.println("\nsearchBook("VFP二级考前指导")--"+bm.note);
                                                  ^
C:\Users\xuqianqian\Desktop\testExample2_4.java:67: 需要 ';'
  System.out.println("\nsearchBook("VFP二级考前指导")--"+bm.note);
                                                          ^
  相关解决方案