Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Strang assertion problem  RSS feed

Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear sir,
I read a materail talking about the assertions, its example is strange.
here is the content :
public aClass {
public void aMethod(int argument) {
Foo foo = null;
//...somehow get a Foo object
if(!(foo != null ) {
throw new AssertionError ( "can
t get a Foo, argument="+argument);
the problem is why the method doesn't have throws clause to indicate it throw AssertionError,
just like public void aMethod(int argument) throws AssertionError {......}
Please help
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Benson, it's because assertionError is a subclass of Error. Remember that unchecked exceptions are exceptions that are subclass of RuntimeException and Error. You can declare it if you want, but the compiler only complains when dealing with checked exceptions.

[ August 13, 2003: Message edited by: Andres Gonzalez ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!