Check out example codes for "java assertions". It will help you in understanding the concepts better.

Code Example 1

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AssertionExample {

    /**
     * The assertionExample function
     * uses multiple assertions for the purpose of example;
     * Usually in one method it is recommended to have 1 assertion;
     */
    @Test
    public void assertionExample()
    {
        Assertions.assertEquals(2+2,4);

        Assertions.assertNotEquals(6+3,10);

        Assertions.assertTrue("Radu".length()==4);

        String tester = null;

        Assertions.assertThrows(NullPointerException.class,()->tester.equals("emptyString"));
    }
}

Code Example 2

// Java program to demonstrate syntax of assertion 
class Test { 
    public static void main(String args[]){ 
        int value = 15; 
        assert value >= 20 : " Underweight"; 
        System.out.println("value is "+value); 
    } 
}

Learn ReactJs, React Native from akashmittal.com