Results 1 to 4 of 4
  1. #1
    sfe23's Avatar
    sfe23 is offline Member
    Join Date
    Feb 2009
    Posts
    42
    Rep Power
    0

    Default throw an exception

    What does it really mean to throw an exception when checking for errors?
    like when the stack is full we throw an exception. How does this work?
    what does the exception do? could we also print a message for the user when throwing an exception?
    what's the difference between throwing an exception or simply using a System.out.println(" error .." )?

    Can someone give a very simple example?

    I know I'm asking too many questions! I really like to know what this means :)

    thanks

  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default a good link...

    The topic of exceptions is too vast for a "simple example"... the following link explains Java exceptions very well, including how to throw an exceptions w/examples:

    Lesson: Exceptions (The Java™ Tutorials > Essential Classes)

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    These are all very good and important questions but may be a bit broad to be answered within the confines of this forum. I think that your best bet is to go to the source, the Sun tutorials and have a read. It's quite well written and should answer all these questions and then some:

    Lesson: Exceptions (The Java™ Tutorials > Essential Classes)

    Edit: Ninja'd by Chris! Good going!

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default yeah...

    hehehe... Furball .... look above... finally, one for the home team :)

    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. throw exception
    By GIRISH PATEL in forum New To Java
    Replies: 4
    Last Post: 04-23-2009, 04:35 AM
  2. Replies: 1
    Last Post: 12-13-2008, 01:24 AM
  3. exception
    By thamizhisai in forum Advanced Java
    Replies: 9
    Last Post: 05-30-2008, 08:47 AM
  4. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  5. Difference between Throws and Throw
    By Poonam in forum New To Java
    Replies: 7
    Last Post: 02-06-2008, 04:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •