Yes, the args parameter is an array of strings that come from the command line. When you execute the java executable there will be
(1) Some switches like -cp etc
(2) Then the class name: in this case CLDemo
(3) Then some other strings
It's the ones in the last category that will be delivered to the main() method as the args
The usefulness lies in the fact that the arguments can tell the CLDemo program what you want it to do. To take a non Java example you could issue the command:
which will display the contents of the CLDemo.java file. It is necessary for the type command to be told the name of the file you wish to display! The way it finds out is by having access to the command line arguments. In this case there is one of them: the file to display.
The reason why your program prints "arg: foo" etc is that you have written a for loop that goes through the args
array and prints the contents.
I was too slow
I'm glad you've got it sorted out!