• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Doubt in Exception Handle and Declare

 
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.








 
Ranch Hand
Posts: 31
MyEclipse IDE C++ Java
  • 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]=...}
 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic