Results 1 to 4 of 4

Thread: assertion doubt

  1. #1
    jomypgeorge is offline Member
    Join Date
    May 2010
    Posts
    90
    Rep Power
    0

    Default assertion doubt

    hi friends,

    now i am learning assertions in java.
    my doubt is what is the difference of assertions from an error

    for example:

    assert number < 0 : "Negative Number"

    and

    if (number < 0) throw(new Error("Negative Number"));

    what is the difference between these two?


    thanks in advance......

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

    Default

    In the case where number>=0, the assert version will only result in an error if assertions are enabled at runtime. In that case it will be an instance of AssertionError.

    Assertions were described as part of the 1.4.2 documentation guide in the section Programming with Assertions.

  3. #3
    jomypgeorge is offline Member
    Join Date
    May 2010
    Posts
    90
    Rep Power
    0

    Default

    thanks pbrockway2

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,585
    Rep Power
    12

Similar Threads

  1. doubt
    By Chris555 in forum Networking
    Replies: 0
    Last Post: 08-05-2009, 03:58 PM
  2. Doubt
    By winkodes in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 12-20-2008, 09:34 PM
  3. [SOLVED] about Assertion...
    By newmember in forum New To Java
    Replies: 4
    Last Post: 09-26-2008, 04:31 PM
  4. doubt
    By shaju_inspira in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-18-2008, 09:38 AM
  5. doubt in jms
    By veena in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 01-05-2008, 02:42 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
  •