| Author |
throw and throws
|
Jello Yao
Greenhorn
Joined: Jan 05, 2003
Posts: 13
|
|
|
Does the only difference between using throw and throws is the English grammer?
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
No, "throws" is used in method declarations, as in void foo() throws SomeException {} whereas "throw" is used to actually do throw an Exception, as in throw new SomeException();
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
I.e. "throws" is just a warning, meaning "this method may throw the following exception". While "throw" is a command - "throw an exception right now".
|
"I'm not back." - Bill Harding, Twister
|
 |
Robbie shi
Greenhorn
Joined: Jan 05, 2003
Posts: 28
|
|
"throws" is just like try-catch statement Excepiton may happen "throw" means that the exception throws -- Robbies ----------------------------- 1.java IDE tool : JawaBeginer 2.Java Jar tool : JavaJar http://www.pivotonic.com
|
 |
Jello Yao
Greenhorn
Joined: Jan 05, 2003
Posts: 13
|
|
Thanks for the help!
|
 |
 |
|
|
subject: throw and throws
|
|
|