第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

這個(gè)程序一直在21行和99行拋出空指針異常,誰知道怎么回事?

這個(gè)程序一直在21行和99行拋出空指針異常,誰知道怎么回事?

慕粉2347349578 2017-03-08 22:30:13
package overlaod;//import java.awt.print.Book;public class OverloadTest { private Book[ ] booksList;? ? void OverloadTest(Book[] booksList ){ Book booskList[] = { new Book("郁達(dá)夫隨筆:傷感旅行","郁達(dá)夫","北京大學(xué)出版社",38.0f), new Book("教育法學(xué)","李曉燕 主編","高等教育出版社",23.9f), new Book("普通化學(xué)原理與應(yīng)用","畢德樂","高等教育出版社",89.0f), new Book("機(jī)關(guān)工會(huì)工作指南","郭紅美","中國(guó)工人出版社",36.0f) }; this.booksList = booksList; } OverloadTest(Book ... book){ booksList = book; } void getBookInfo(){ System.out.println("全部圖書:"); //System.out.println(booksList); for(int i = 0; i< booksList.length; i++){ System.out.println("\t"+(i+1)+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].publisher+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].price); } } void getBookInfo(float price){ System.out.println("價(jià)格為“"+price+"”的圖書"); int m = 1; for(int i = 0; i< booksList.length; i++){ if(booksList[i].price == price){ System.out.println("\t"+m+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].publisher); m++; } } } void getBookInfo(String publisher){ System.out.println("出版社為“"+publisher+"”的圖書:"); ?int m = 1; for(int i = 0; i < booksList.length; i++){ if(booksList[i].publisher == publisher){ System.out.println("\t"+m+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].publisher); m++; } } } void getBookInfo(float price, String publisher){ System.out.println("價(jià)格為“"+price+"”且出版社為“"+publisher+"”的圖書:"); int m = 1; for(int i = 0; i < booksList.length; i++){ if((booksList[i].price == price) & (booksList[i].publisher == publisher)){ System.out.println("\t"+m+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author); m++; } } } void getBookInfo(String publisher,float price){ System.out.println("出版社為“"+price+"”且價(jià)格為“"+publisher+"”的圖書:"); int m = 1; for(int i = 0; i < booksList.length; i++){ if((booksList[i].publisher == publisher) & (booksList[i].price == price)){ System.out.println("\t"+m+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author); m++; } } } void getBookInfo(float...price) { String s =""; int ?m = 1; for(float bookPrice:price){ s = s + bookPrice + " "; } System.out.println("價(jià)格為“"+s.trim( )+"”的圖書:"); for(float bookPrice:price){ int i = 0; while(i < booksList.length){ if(bookPrice == booksList[i].price){ System.out.println("\t"+(i+1)+"."+booksList[i].title+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].author+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].publisher+ ? ? ? ? ? ? ? ? ? ? "\t"+booksList[i].price); } i++; } } } //void getBookInfo(float[] price){}//方法重復(fù) public static void main(String[ ] args){ OverloadTest ?overloadTest = new OverloadTest( ); overloadTest.getBookInfo( ); overloadTest.getBookInfo(36f); overloadTest.getBookInfo("高等教育出版社"); overloadTest.getBookInfo(89f,"高等教育出版社"); overloadTest.getBookInfo("北京大學(xué)出版社",38f); overloadTest.getBookInfo(36f,28f); overloadTest = null; overloadTest = new OverloadTest( new Book("藝術(shù)批評(píng)學(xué)","陳漢青","北京大學(xué)出版社",28.0f), new Book("工程力學(xué)","范欽山","高等教育出版社",71.0f)); overloadTest.getBookInfo( ); }}class Book{ String title; String author; String publisher; float price; Book(String title, String author, String publisher, float price){ this.title = title; this.author = author; this.publisher = publisher; this.price = price; }}
查看完整描述

1 回答

?
DaRKeViL

TA貢獻(xiàn)21條經(jīng)驗(yàn) 獲得超3個(gè)贊

沒發(fā)現(xiàn)哪里報(bào)空指針

查看完整回答
反對(duì) 回復(fù) 2017-03-09
  • 1 回答
  • 0 關(guān)注
  • 1167 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)