• Post Reply Bookmark Topic Watch Topic
  • New Topic

IOException  RSS feed

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class AQuestion
{ public static void main(String args[])
{ System.out.println("Before Try");
try { }
catch(java.io.IOException t)
{ System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}

Dear sir in the above code it is an compile time error that try is not throwing IOException although when i m using in catch That ArrayIndexOutOfBoundsException no problem at all why?

with regard

Arun kumar maalik
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IOException is a checked exception, and ArrayIndexOutOfBoundsException is an unchecked exception.

You can't have a catch block for a checked exception when there isn't a possibility of the checked exception occuring within the try block.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!