intellij idea - I get an error : Error:(36, 12) java: exception InvalidISBN_EXCEPTION is never thrown in body of corresponding try statement -


      {        try {             for(int i=c;i<no;i++){             system.out.println("enter barcode :");            isbn = input.next();            system.out.println("yearofpub :");            yearofpub = input.nextint();}             loop =false;          }        catch (invalidisbn_exception e) {            // throw  new invalidisbn_exception(isbn);            system.err.printf(" error %s", e);            system.out.println("wrong isbn");            loop = true;         }    } while(loop); 

i have class store , class invalidisbn_exception , try catch error how can fix ?

unless in code (your try block)

 for(int i=c;i<no;i++){         system.out.println("enter barcode :");        isbn = input.next();        system.out.println("yearofpub :");        yearofpub = input.nextint();}         loop =false; 

declares throw checked exception of type invalidisbn_exception, compiler complain. saying can catch error nothing ever declares throw it. have remove try/catch code around code.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -