• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in Exception Handle and Declare  RSS feed

 
Sami Devine
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this program, with method m1 throwing a checked exception, I expected that both methods m1 and m2 need to declare that they are throwing an Exception. The program compiles fine without this. When is a declaration needed.








 
Yunnan Zhou
Ranch Hand
Posts: 31
C++ Java MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you may not check array's length.java will do it.
if you hava to do like this,you can try an catch in the code for(int i.....){a[i]=...}
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any checked exceptions. I only see ArrayIndexOutOfBoundsException which is an unchecked exception, so it doesn't need to be declared to be thrown.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!