 Hello friends, I am Sanjay Gupta. In this video I am going to demonstrate you how you can use assert keyword in Java. Before starting you can subscribe my YouTube channel by clicking on the link which is available at bottom right corner of this video. You can download my app Techimage that is available on Google Play. You can connect with me by following these details. So first of all you have to understand what assert keyword is. So in this slide first point says assert is used during program development to create an assertion which is a condition that should be true during the execution of the program. So assertion is a condition. For example you might have a method that should always return a positive integer value. You might test this by asserting that the return value is greater than zero using an assert statement. At runtime if the condition is true no other action takes place. However if the condition is false then an assertion error is thrown. So if you have implemented assert keyword in your program and if assert condition is true then a normal execution of program will take place. If assertion condition is false then an assertion error will be thrown. Last point says assertions are often used during testing to verify that some unexpected condition is actually met. They are not usually used for released codes. So you can say that assertions are used for only testing purpose. Now I am going to demonstrate a code. You can see an example. Here name of class is assert demo. It is containing a variable val whose value is three and it is a static variable. Then GATNUM method is defined which is returning val minus minus. Its return type is int and it is also a static method. The main method inside main loop starting from zero to ten it is calling GATNUM method. So GATNUM will return a value which will be received by n. Here in line number ten assert keyword is used and condition is n greater than zero. So it will fail when n is zero. So if condition n greater than zero is true then system.out.println will print a value of n on console. If n equals to zero then an error message will be displayed on console so that you can check whether this assertion condition is true or false. So to understand this program I am executing this code so I have open command prompt. This code is saved in d drive inside d drive practice folder. So first of all I have to compile this code. So I am typing java c assert demo dot java. It is compiled successfully. Now I have to run it by using java. Now if you want to enable assertion then you have to use minus ea and then name of class file. So you can see n is three n is two n is one and when value of n is zero an error message has been displayed here. So friends with the help of assertion you can apply a test condition in your code. If assert condition is true then normal execution of code will be done. If assertion condition is false then program will be terminated and an error message will be displayed on console. So you can implement this in your system so that you can understand how assertion is working. If you want to watch more programming related videos you can subscribe my youtube channel. Thank you for watching this video.