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. Advertisements

  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. Advertisements

  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
    Likes Received:
    0
    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. Advertisements

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:
    507
    Eliyahu Goldin
    Jun 6, 2005
  2. cyberdude

    Differences between C++ and Java

    cyberdude, Sep 13, 2003, in forum: Java
    Replies:
    36
    Views:
    6,745
    Will Hartung
    Sep 17, 2003
  3. Paul Morrison
    Replies:
    1
    Views:
    2,057
    Joseph Dionne
    May 1, 2005
  4. Roedy Green

    Differences between C++ and Java

    Roedy Green, Nov 16, 2005, in forum: Java
    Replies:
    179
    Views:
    3,800
    Dimitri Maziuk
    Dec 5, 2005
  5. Rasti
    Replies:
    5
    Views:
    564
    Joe Gottman
    Nov 6, 2003
  6. Paul Morrison
    Replies:
    15
    Views:
    682
    Tim Rentsch
    May 6, 2005
  7. Home_Job_opportunity
    Replies:
    0
    Views:
    683
    Home_Job_opportunity
    Jan 8, 2009
  8. Home_Job_opportunity
    Replies:
    0
    Views:
    769
    Home_Job_opportunity
    Jan 14, 2009
Loading...