Results 1 to 6 of 6

Thread: Use of assertion in java

  1. #1
    Join Date
    Dec 2009
    Posts
    48

    Use of assertion in java

    Hello friends,

    I have to ask one question regarding the assertion of java programming. I am not able to understand the assertion in java. I don't know the exact use of assertion in java. I have referred various java programming books but didn't get enough information over this. If you know the use of assertion in java, then please let me know that. You help would be greatly appreciated.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Use of assertion in java

    Hi,

    Assertions contain Boolean expressions that define the correct state of your program at specific points in the program source code. Assertions can be used to detect errors that may otherwise go unnoticed.Use assertions for internal consistency checks, i.e. to indicate you screwed up, not the user of your class. Assertion used to presents an overview of design by contract. I hope now you have understood the assertion concept.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Use of assertion in java

    In java programming language "assertion" is basically used to represents an overview of design by contract. Standard Edition (J2SE) released 1.4 which comprises built-in facility for assertion. It shows how to roll your own assertion capabilities. It also comprises the information about how to use assertions. It important advantages of this is that is has guidelines for to use assertions. You can use assertions to detect errors that may otherwise go unnoticed.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Use of assertion in java

    An assertion reflects a state that should not ever occur & wasn't expected, where the application cannot continue executing for one reason or another, whereas an exception indicates a state that is not considered "normal", but that was not unexpected, and from which it might be possible to recover. Assertions contain Boolean expressions that define the correct state of your program at specific points in the program source code.assertions are most useful during the debugging phase, whereas exceptions are considered part of regular program flow and error handling.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Use of assertion in java

    An assertion in java programming has a Boolean expression and which, if evaluated as a false, indicates a bug within in the code. The advantage of Assertions is that it improve the odds that the behavior of a class that expectations of its clients. It also helps for the developers write code that is more correct, more readable, and easier to maintain. Assertions in java language is excellent for documenting assumptions and invariants about a class. This mechanism provides a way to detect when a program starts falling into an inconsistent state.

  6. #6
    Join Date
    Nov 2009
    Posts
    74

    Re: Use of assertion in java

    An assertion has a Boolean expression that, if evaluated as false, indicates a bug in the code. The assertion used to detect the unnoticed errors. Assertions includes the boolean expressions and which define the correct state of the java program at specific points in the program source code. The designers of the Java platform, however, didn't include support for assertions. This mechanism provides a way to detect when a program starts falling into an inconsistent state.

Similar Threads

  1. Sniper Ghost Warrior Assertion Failed
    By TanujC in forum Video Games
    Replies: 6
    Last Post: 30-06-2010, 12:23 AM
  2. New PNR assertion failed
    By Devabrata in forum Windows Software
    Replies: 6
    Last Post: 05-06-2010, 06:40 AM
  3. Assertion failed! in Warzone2100.
    By Shaan12 in forum Video Games
    Replies: 5
    Last Post: 31-12-2009, 12:45 AM
  4. Replies: 4
    Last Post: 29-12-2009, 02:23 PM
  5. Confused about assertion concept
    By reetus in forum Software Development
    Replies: 5
    Last Post: 27-11-2009, 03:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,327,421.09553 seconds with 17 queries