the differences between keyword thow and thows in java

Discussion in 'Java' started by hunglduc, Feb 23, 2009.

  1. hunglduc

    hunglduc Guest

    can u please answer for me
     
    hunglduc, Feb 23, 2009
    #1
    1. Advertising

  2. hunglduc wrote:
    > can u please answer for me


    There are no such keywords as 'thow' or 'thows'.

    You might be referring to 'throw' or 'throws'. Incidentally, have you
    checked with your textbook/classmates/teacher/professor yet? This sounds
    like stuff you should be covering in class...

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Feb 23, 2009
    #2
    1. Advertising

  3. On 2009-02-23 10:23:13 -0500, hunglduc <> said:
    > the differences between keyword thow and thows in java
    >
    > can u please answer for me


    Neither "thow" nor "thows" are keywords in Java. Spelling matters.

    "throw" is a statement fragment. A "throw" statement causes an
    exception to be thrown when it's evaluated.

    "throws" is a declaration fragment. A method may be declared to
    "throws" a list of exceptions, which the calling method must be
    prepared to handle.

    For more details, see
    - http://java.sun.com/docs/books/tutorial/essential/exceptions/
    - http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html

    -o
     
    Owen Jacobson, Feb 23, 2009
    #3
  4. hunglduc

    Lew Guest

    hunglduc wrote:
    >> can u  please answer for me

    >


    The word is "you", not "u". Spelling counts in Java, as with all
    computer languages, so it is good to practice good spelling in the
    Java forums, too. For example, if you try to use "thow" or "thows" in
    your code to mean 'throw' or 'throws', respectively, it will not
    compile.

    Also, it is conventional to state your question in the body of your
    post, not just the subject line. It makes it marginally easier for
    others to follow the conversation in these discussions.

    Your question about the difference between 'throw' and 'throws' is
    completely answered in the Java Language Specification (JLS):

    <http://java.sun.com/docs/books/jls/third_edition/html/
    exceptions.html>
    That section details the semantics of the 'throw' command.

    The 'throws' keyword is explained in detail in
    <http://java.sun.com/docs/books/jls/third_edition/html/
    classes.html#8.4.6>
    for methods and
    <http://java.sun.com/docs/books/jls/third_edition/html/
    classes.html#8.8.5>
    for constructors.

    The tutorial for exceptions is at
    <http://java.sun.com/docs/books/tutorial/essential/exceptions/
    index.html>

    You will find java.sun.com an excellent first source of information
    for Java programming. The JLS and the tutorials are where you should
    start for language understanding; the API Javadocs
    <http://java.sun.com/javase/6/docs/api/>
    for information about the standard APIs.

    --
    Lew
    No doubt I misspelled something in this post, but I tried, I really
    did.
     
    Lew, Feb 23, 2009
    #4
  5. hunglduc

    code learner

    Joined:
    Dec 24, 2010
    Messages:
    19
    throw is used to throw an exception
    throws is used to tell a method can throw an exception
     
    code learner, Jan 9, 2011
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    1
    Views:
    427
    Eliyahu Goldin
    Jun 6, 2005
  2. Replies:
    6
    Views:
    458
    Peter Otten
    May 10, 2007
  3. Hamilton, William

    RE: keyword checker - keyword.kwlist

    Hamilton, William, May 10, 2007, in forum: Python
    Replies:
    4
    Views:
    356
  4. Home_Job_opportunity
    Replies:
    0
    Views:
    503
    Home_Job_opportunity
    Jan 8, 2009
  5. Home_Job_opportunity
    Replies:
    0
    Views:
    589
    Home_Job_opportunity
    Jan 14, 2009
Loading...

Share This Page