• Post Reply Bookmark Topic Watch Topic
  • New Topic

Core Java Doubt  RSS feed

 
Pratapchandran Ramakrishnan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plz give me the exact diff between
throw and throws
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For these simple problems, please post your questions at:
http://www.coderanch.com/forums/f-33/java


If you declare XXXException is the only exception the method to be thrown, and if another exception YYYException is thrown inside the method, you will get compliation errors. Noticed that the throws clause only applied to non-RuntimeException.

throw is used to throw an exception inside a method.


Nick
[ January 07, 2005: Message edited by: Nicholas Cheung ]
 
Anusorn Swasdee
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ีUse throws after method declaration to indicate that the following exceptions may be thrown.

Use throw to throw exceptions.

ex
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Posts: 12156
256
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pratapchandran,

Welcome to JavaRanch.

We have many forums here, and we try and keep the focus of the forums to a specific area of interest. This particular forum (SCJD) is for those candidates who are attempting to become recognised as Sun Certified Java Developers. This certification assumes that candidates are already well versed in core java issues.

Although some members of this forum may very well be able to answer your question, you would be better off asking about this in the Java in General (beginner) forum.

I have therefore moved this post to that forum.

Regards, Andrew
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!