This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes difference between throw and throws Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between throw and throws" Watch "difference between throw and throws" New topic
Author

difference between throw and throws

priyanaka jaiswal
Ranch Hand

Joined: Jun 03, 2011
Posts: 79
Hi all,

What is difference between throws and throw?

Thanks in advance
Vijay Tidake
Ranch Hand

Joined: Nov 04, 2008
Posts: 146

Hi,

throws is used in method declaration,which may throw a exception(Checked or Unchecked)

throw is used to throw an Exception from a code.

for ex



Thanks


The important thing is not to stop questioning.Curiosity has its own reason for existing.
akhter wahab
Ranch Hand

Joined: Mar 02, 2009
Posts: 151

priyanaka jaiswal wrote:Hi all,

What is difference between throws and throw?

Thanks in advance


check this link webpage


Start Earning Online||Start Earning Using Java
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

throws-used with method declaration indicates that the method may throw that type of exception
throw-used to throw an exception object
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Vijay Tidake wrote:
throws is used in method declaration,which may throw a exception(Checked or Unchecked)

dont *throws* unchecked exception with method declaration, it become meaningless . because it wont intimate about exception to other programmer who will use your method!
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11170
    
  16

If i said "Throw the ball", I'm telling <someone> do do something.

If i said "Fred throws a fastball", I am describing something Fred can do.

-------

You use "throw" to tell the jvm that an exception should be thrown. You use "throws" to describe what a method can do.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between throw and throws
 
Similar Threads
Difference
throw and throws
throws and throw
throw and throws
Throws and throw