Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bonni Garcia   on May 08 In Java Category.

  
Question Answered By: Kiet Jainukul   on May 08

public void  anotherMethod() throws  BadObjectException{
try {
doSomething();
--------------->> }catch(BadObjectException be) {
System.out.println("BadObjectException");
}
}

--------------->> The doSomething method does not throw the BadObjectException.
so the catch statement wont be reached.

You can very well do with removing the try catch block.else have the doSomething
method defined with throws clause.

public void doSomething() throws BadObjectException

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Wats Wrong With this Code ? Or get search suggestion and latest updates.


Tagged: