Assert Statement in Java

Java Assertion and AssertionError

Java Assertion is a pre-condition which checks for the program correctness at a specific code location. Coder will place these assertions at needed location of the program to check it meets certain requisites to go on with the rest of the code flow. In java, a condition which follows the assert keyword evaluates to true or false.

Recent Posts

  • Custom Mapping Mode in VC++ Via MM_ISOTROPIC

    Window and Viewport Extends vs Pixels

    In the previous MFC Article, we examined how the Mapping Modes works while performing the drawing operation. In this example, we will see how we set the custom mapping modes. Our goal is below:

    1) Set mapping mode so that the horizontal logical unit is 1 Centimeter (cm). Simply, 1 Unit = 1 cm in X axis.
    2) Also, 1 Unit = 1 cm in Y Axis.
    3) Positive X is towards left.
    4) Positive Y is going Upwards.
    5) The Drawing origin should be in screen center.

    We can achieve the above goal by using the Custom Mapping mode MM_ISOTROPIC.

  • Custom Exception in Java – Creating & Using

    CheckedAndUncheckedException

    In Java there are many Exception types to handle a unique exception. There are groups like security related exceptions, file handling related exception and DB operation related exceptions, etc. If you want to handle an exception that is more exact to your business Logic, you can go for ‘Custom Exception’. Before we move on to the topic, let us learn Exception Category and this will help us decide what kind of exception we can create.

  • Exception Bubbling in Java

    Exception Bubbling in Java

    In java and modern OOPS language, an Exception moving from one method to other method is what we call as Exception Bubbling. In java, a method can call other method. The Called method can call one more method. These kinds of calling sequence continue and we can see all the methods in a call stack for a given point in time.

  • Method Level CAS (Code Access Security)

    Example - CAS Method Level Security

    The Method Level Security comes with different Security Actions and those are below:
    1. Demand Action
    2. Link Demand Action
    3. Inheritance Demand Action
    4. Deny Action
    5. PermitOnly Action
    6. Assert Action

    The text boxes (Markers 1 & 2) will display the value of the environment variables UserName and SecTest. The two read buttons (Markers 3 & 4) try to read those environment variables and sets the retrieved values in the corresponding text boxes 1 and 2.

    The Radio button options (Marker 5) invoke the methods which had applied with the corresponding security attributes. We are going to debug the methods by picking an option here (marker 5) and hitting the Read buttons.

    The check box (Marker 6) is used to explain how the security actions like Deny and Demand are invoked through imperative method. One can use the same imperative style for other security actions as well.