 Hello friends, I am Sanjay Gupta. I welcome you on my channel. You can watch various program related videos on my channel. So search it, subscribe it. You can find more than 800 videos on my channel. In this video, I am going to demonstrate you how you can calculate factorial of a number which is passed through command line arguments in Java. So I have named the class as CMD. Inside this class, I am writing main method definition. In main method header line, we use string array named as ARGS, which receives command line arguments in case of Java. So I have to use this array to retrieve command and argument. Then I can use that number to calculate factorial. But remember that the ARGS array will be receiving number in form of string. So I need to convert that string into integer. Then only I can calculate that numbers factorial. So I have declared some variables. First I am going to convert ARGS 0 into integer. So parse and method converts string into integer. It means ARGS 0 index location will be converted into integer and the value will be stored inside and variable. Now I can calculate factorial of n easily with the help of a loop. Loop is repeating n times. Calculation will be f equals to f into i. This is the logic for calculating factorial. After completion of loop, factorial value will be available in f variable. So I am going to print that on output screen. This way I have implemented the complete code in front of you. Here arguments will be passed from command line and then that argument will be converted into integer. And then its factorial will be calculated and the result will be displayed on output screen. So I have to compile and execute the code. You can see I have compiled code successfully. Then I am executing it and I am passing five as command and argument. It means I need to calculate factorial of five. You can see the output. It is showing correct result. It is displaying 120 as factorial of five. Let's pass another number six. It is showing factorial equals to 720 which is the factorial of six. It means code is working properly. It is displaying correct results. I hope you have understood how we can calculate factorial of a number using command and arguments. So this way you can perform any particular logic in Java through command line arguments. I hope you have understood everything. If you want to watch more programming related videos, you can follow my YouTube channel. Thank you for watching this video.