Results 1 to 7 of 7
  1. #1
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default Exception problem !!

    class Test{
    public static void main(String args[]) throws Exception{
    try{
    throw new Exception();
    }
    finally{
    System.out.println("No Error");
    }
    }
    }

    Please help me to understand this simple program..
    I've no idea about throw new Exception(); line

    I need to know what is happing there plus what is different between throw and throws

    Thanks

  2. #2
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default

    thorws is ok, we declare we are not going to handle that excpetion!!

    Can we use throw new Exception(); other than try block???

  3. #3
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

  4. #4
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default

    Thank you for your reply..

    That site does not talk about different between throws and throw right!!

    as far as i understood, throws with "s" means it says i'm not going to handle this excpetion,

    Throw means creating exception object and handle it~!!

    Pl;ease let me know, am i correct????

    And, since new throw Exception to handle the excpetion, that is ONLY used in try block!! am i correct ??

    Thanks you

  5. #5
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    yes you are right
    Skype: petrarsentev
    http://TrackStudio.com

  6. #6
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    This link might help you understand it more: How to Throw Exceptions

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  7. #7
    chathura87 is offline Member
    Join Date
    Feb 2011
    Posts
    27
    Rep Power
    0

    Default

    Quote Originally Posted by goldest View Post
    This link might help you understand it more: How to Throw Exceptions

    Goldest
    Yeap, its more short and sweet.. Thanks a lot

Similar Threads

  1. Exception handling problem
    By computerbum in forum New To Java
    Replies: 2
    Last Post: 04-17-2010, 04:15 PM
  2. Exception-Based Problem
    By Hax007 in forum New To Java
    Replies: 2
    Last Post: 12-09-2009, 12:17 AM
  3. Problem using EBI Webservice getting Exception
    By tealc76 in forum Advanced Java
    Replies: 0
    Last Post: 11-21-2009, 07:20 PM
  4. Problem with null pointer exception?
    By dunafrothint in forum AWT / Swing
    Replies: 3
    Last Post: 11-11-2009, 04:34 PM
  5. Problem with JSP exception handling page
    By sidster in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-19-2008, 08:28 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
  •