 Hello friends. I am Sanjay Gupta. I welcome on my channel. You can watch various programming related videos on my channel. You can search it. It contains more than 800 videos. In this video, I'm going to demonstrate how you can use command and arguments in Java. So here I'm using CMD as name of class. Then I will be implementing main function. Inside main function, I will be writing some instructions. First, see here in every Java program, you might be using main function. And in these parenthesis, you might be using this ARGS array of string type. So this array is used to hold the arguments which are passed through command prompt. If you want to check values of those arguments, then you can print them like this. And if you are passing only one argument, then that argument will be stored at 0th index of ARGS array. So it will be printed on output screen through this system.out.println command. So I'm saving this code first time executing this small segment of code so that you can understand how we can pass or where we can write that argument so that it will be received in ARGS array. So first we need to compile the code after successful compilation. When you are executing the code with Java command, then you have to pass that command and argument. So here I am passing my name as command and argument. You can see the output argument equals to Sanjay. So 0th index is storing Sanjay as command and argument. If you are passing more than one arguments, then those arguments will be stored at various indexes like 0, 1, 2, and so on. In that case, you can write like this. If you are passing two arguments, you can print ARGS 0 and then ARGS 1. Again, I'm going to compile and execute this code. You can see this time it is printing two arguments, my first name and last name. Now suppose you want pass n number of arguments whenever you execute this code, then you require a flexible code which can receive two arguments, three, four, and so on. So in that case, you have to use a loop to process this ARGS array. Now see this code segment. I have implemented a loop starting from zero. Here condition is less than ARGS dot length. In Java, each array contains a particular attribute named as length, which provides size of the array. So if you are passing three arguments, this loop will repeat three times. If you are passing five arguments, this loop will repeat five times. And then ARGS of fire will be printing arguments on output screen. So this code can receive any number of arguments whenever it will be executed. Now I have to compile and execute this code so that we can test it. This time I will be passing names of different countries. So first time I am passing names of three countries. You can see the output. It is showing all the names properly. Now see it carefully. I am not compiling the code. I am just executing it without making any change in the code. I am adding some more names of countries. This time I am passing five country names as command line arguments. So it is processing all those names properly. So this way I hope you have understood how we can receive command line arguments in main method, how we can process them, whether they are in one quantity to quantity or n number of quantities. So this way I hope you have understood why ARGS string array is available in main method. I hope you have understood it well. If you want to follow me, you can subscribe my YouTube channel. Thank you for watching this video.