Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception handling  RSS feed

 
Alvin chew
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 ]
 
somkiat puisungnoen
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
 
Pradeep bhatt
Ranch Hand
Posts: 8933
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


 
saran ram
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!