 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can check whether the number is even or odd in Java. So I am writing the code in front of you so that you can understand how we can check whether the number is even or odd. First of all, I am going to import a package whose name is util. Inside this package, a class is predefined, that is scanner. I am going to use this class to read input from user. Then name of class, even or inside this class, I am going to define main method. So this is the header line of main method. This ARGS will be receiving command line arguments if they are provided. Return type of main method is void. It is static, which will be called automatically and it is public so that it can be called outside the package. Now I am going to declare a variable that is int n. Now I have to receive input from user. For that purpose, I have to create instance of scanner class. Name of instance is input. In constructor of this scanner class, I am passing system.in so it will be receiving all the inputs from the console. Now through system.out.println, the message enter a number will be displayed on output screen. To receive input from user, I am calling a method whose name is next int. This next int method is defined in scanner class. That's why I have created instance of scanner class that is input. So input is calling next int method which is available in scanner class. So user input will be available inside n variable. Now I am going to apply the logic for checking whether the number is even or odd. So this is a simple logic. If n modulus to modulus means remainder. If number is divisible by 2, then its remainder will be equal to 0. Then I can print number is even. If this condition is false, then I can print number is odd. So this way I have implemented the fls in front of you which are checking whether the number is even or odd. Now after complete implementation of the program, I am going to save this code. So I am saving this code in d drive inside java folder with even or dot java. So you can see this code has been saved in java folder. Now I am going to execute this code. So I am opening command prompt. I am moving to d drive then in java folder. So right now my current location is d java folder. Now I have to compile the code first. So for compilation we have to use this command javac then name of file dot java. I am pressing enter key. Sorry it is showing an error. I forgot to use this double codes. So you have understood that if you are making any mistake in your code, compiler will show that error with line number and the description of error will also be displayed. So now I have removed the error. So after removing the error, you have to again save your code with control s. Second time you don't have to provide any name because you have already provided name for the file. Now I am compiling this code. This time you can see it is not showing any error. It is compiled properly. Now I have to execute the code. For that purpose I have to type java and then only name of file that is even or. You can see it is asking for a number. I have entered 5. It is showing number is odd. Again I am going to execute this code. It is again asking for a number. This time I am entering 10. You can see it is showing number is even. So this way I have checked both the numbers even as well as odd with the help of this java program. I hope you have understood how I have implemented the code in front of you. If you want to watch both programming related videos, you can subscribe my YouTube channel. You can search my channel by just typing my name Sanjay Gupta in YouTube. Thank you for watching this video.