Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Uses of throws keyword

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Uses of throws keyword

    Hi friends i am having doubt with throws keyword in java. I studied in many books and many forums but i got same answer that is throws is used to "checked Exception" so my doubt is what is the exact use of throws keyword. i think try,catch itself i can able to solve all the Exception problems.so how throws deffer from try and catch, please give solution for my question.


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    1,069
    Thanks
    7
    Thanked 215 Times in 191 Posts

    Default Re: Uses of throws keyword

    "throws" is used when declaring a method which may result in an exception where the method itself does not handle the exception using try/catch.

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

    Whether you decide to handle an exception in the method where it occurs or in the caller of the method (or somewhere higher up the call chain) is a matter of design. You have the choice: handle an exception right where it occurs (with try/catch), or have the caller handle it (with throws).

Similar Threads

  1. keyword definitions needed
    By BLUEJ in forum Java Theory & Questions
    Replies: 5
    Last Post: December 8th, 2012, 04:56 PM
  2. [SOLVED] The 'new' Keyword
    By TheSlowLearner in forum Object Oriented Programming
    Replies: 17
    Last Post: August 7th, 2012, 01:05 AM
  3. Super Keyword
    By shruthi in forum Java Theory & Questions
    Replies: 12
    Last Post: October 13th, 2011, 04:31 PM
  4. keyword Extends
    By chronoz13 in forum Object Oriented Programming
    Replies: 3
    Last Post: November 27th, 2009, 07:30 AM
  5. How to highlight search keyword in text?
    By Mohd in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: February 1st, 2009, 06:35 AM