• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Exception handling  RSS feed

 
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i confusing on the usage of throw and throws terms in exception handling ..do you mind to explain briefly on these, mr.ian ..thank you !!

[GDB - Subject edited as this question is not specific to the book.]
[ October 15, 2004: Message edited by: Gregg Bolinger ]
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Alvin chew:
hi, i confusing on the usage of throw and throws terms in exception handling ..do you mind to explain briefly on these, mr.ian ..thank you !!



you can use throws statement in method declaration .



and use throw statement in content of method .

 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception Handling Tutorial
 
Ranch Hand
Posts: 8934
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

The throw keyword means you are throwing an exception.

For e.g.


The throws clause is used in the method signature indicating that the method throws the exception


 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you detect an exceptional condition within a block of code, you will throw an exception object of a specific type using the keyword Throw.

you have to declare checked exceptions that a method can throw using the throws keyword.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!