jump to navigation

Difference between throw and throws November 21, 2006

Posted by Allu in JAVA.

The throw keyword denotes a statement that causes an exception to be initiated. It takes the Exception object to be thrown as argument. The exception will be caught by an immediately encompassing try-catch construction or propagated further up the calling hierarchy.
 The throws keyword is a modifier of a method that designates that exceptions may come out of the method, either by virtue of the method throwing the exception itself or because it fails to catch such exceptions that a method it calls may throw.


1. essamabdelaziz - November 24, 2006

first thank yiou for your useful blog

secon i have aproblem and wish to help me..
sorry to post thi problem here but i don’t knoe how to reach you


i tried to parse adate in format –>dd/mm/yy

but i get an unexpected result can you tell me why?

SimpleDateFormat df=new SimpleDateFormat(“dd/MM/yy”);



//the result will be

Mon Oct 02 00:00:00 GMT+04:00 2006

while i expect


what’s the problem

2. Allu - November 24, 2006

Hi try this…………..

DateFormat formatter = new SimpleDateFormat(“dd/MM/yy”);
Date date = (Date)formatter.parse(“24/11/06”);
String s = formatter.format(date);

3. essamabdelaziz - November 25, 2006

thank you for reply
i knoe this is work but yu convert the date to string
but i need to convert string 24/11/.06
to date 24/11/06
because i have another sysytem and need to set it’s date
for example


4. essamabdelaziz - November 27, 2006

thank you the problem has been solved
but i need afavour from you
i have blog @wordpress.com

and i need to add acounter like yours at my blog to count the visitors
i alraedy have the counter and know how to use it
in blogspot.com
i was adding the url of the counter
in html code of trhe blog
but in wordpress.com
i don’t know where to find html of the blog design can you guide me

Best Regards,
essam abdelaziz

5. vivekanand arya - March 20, 2007

diferrence between throws ,throw and throwable

6. xxxxxxxx - May 17, 2007


7. seema - April 16, 2009

hi i m sending u one file everything is working fine with this . But i want where ever date 00.00.0000 comes there should come a null.plz help me out.

public class sqlldrColFormat {
public static String get( String colName, destDataType) {
String format = “YYYYMMDD”;
if (“TIMESTAMP”.equals(destDataType)) {
return ” Timestamp(8) ” + (char)34 + “YYYYMMDD” + (char)34;
} else if (“DATE”.equals(destDataType)) {
return ” DATE ” + (char)34 + “YYYYMMDD” + (char)34;

} else {
return “”;



8. Gourav Sharma - November 23, 2009

Nice blog..But can u give me one example with explanation of throw and throws…

9. sandesh shinde - October 21, 2010

plz give a clear picture of between throw and throws, and whether throw is used in try,or catch or both.

10. pardeep - June 5, 2011

DO we have 2 main methods in a single program?

11. Deepak Rathod - July 4, 2011

yes we have 2 main method in 1 class but there is no meaning for that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: