Web Design and Development Forums

JAVA Exception

This is a discussion on "JAVA Exception" within the Java, JSP, Cold Fusion section. This forum, and the thread "JAVA Exception are both part of the Program Your Website category.

Old Aug 30th, 2007, 03:36   #1 (permalink)
Junior Member
 
Join Date: Sep 2005
Location: Beyond the seas there's a town,In hand of each child a branch of insight lies,I shall build a boat.
Posts: 20
JAVA Exception

What is difference between throw and throws?

May you give me an example about that?May you explain about override exception?
abalfazl is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Aug 30th, 2007, 20:37   #2 (permalink)
Junior Member
 
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 46
Re: JAVA Exception

The throw keyword is used to actually throw an exception while the throws keyword just tells the compiler which exceptions may be thrown by a method.

Code: Select all
public Object pop() throws EmptyStackException
{
    Object obj;

    if (size == 0) {
        throw new EmptyStackException();
    }

    obj = objectAt(size - 1);
    setObjectAt(size - 1, null);
    size--;
    return obj;
}
See haw throws appears in the declaration of the method and throw appears in its body.
__________________
Viventic Web Design and Application Development
hschmitz is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Aug 31st, 2007, 19:28   #3 (permalink)
Junior Member
 
Join Date: Sep 2005
Location: Beyond the seas there's a town,In hand of each child a branch of insight lies,I shall build a boat.
Posts: 20
Re: JAVA Exception

Hello!
Thanks!

But I mean an example for throw,and another for throws,Thanks in advance!

May someone give me a list of difference between checked and unchecked exceptions?why they called "checked" or "unchecked"
__________________
http://shahcheragh.blogfa.com
abalfazl is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Sep 9th, 2007, 20:19   #4 (permalink)
Junior Member
 
Join Date: Sep 2005
Location: Beyond the seas there's a town,In hand of each child a branch of insight lies,I shall build a boat.
Posts: 20
Re: JAVA Exception

Hi!

http://java.ztor.com/fundamental/main/

Handling Exceptions
You can handle exception otherwise you must declare it. Also you can handle some exceptions and declare others.


Handle Exceptions
Code: Select all
public void myMethod() {
try {
  . . .
}
catch (ExceptionType1 e) {
  . . .
}
catch (ExceptionType2 e) {
  . . .
}
finally {
  . . .
}


Declare Exceptions
Code: Select all
public void myMethod() throws ExceptionType1,ExceptionType2 {
  . . .
}
May someone explain more about difference between these?When do we use declare exception?When to use handle exception?



Quote:
You declare that a method throws an exception if the problem can't be handled in the method. You handle the exception in the method if you can handle the error and continue with the method.

May show this by an example?



Thanks in advance
__________________
http://shahcheragh.blogfa.com

Last edited by karinne; Sep 10th, 2007 at 13:15. Reason: Please use [ code ]...[ /code ] tags when displaying code.
abalfazl is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
exception

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make an exception to an “if ….” vandiermen PHP Forum 2 Sep 10th, 2007 12:59
tried java now c++ alexgeek Perl, Python, Ruby and Others 49 Sep 7th, 2007 06:15
Java/GUI/Server Developer (Java, EJB/Hibernate, SWING) - Berkshire Web JobBot Job Opportunities 0 Jan 16th, 2007 09:30
PHP vs Java Lue PHP Forum 0 Sep 13th, 2006 19:00
Java JDK 1.4.2 gecastill Java, JSP, Cold Fusion 5 Aug 4th, 2005 12:38



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 22:59.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59