When I run the following program:
public class Test
{
public static void main(String[] args)
{
System.out.println(args);
}
{
The main method has a parameter that is an array of String references. So each time you try to print args, it gives you memory location of array 'args' because this String array args located a place in memory for array elements.
That say you have an simple program called 'HelloWorld.java' like this:
public class HelloWorld
{
public static void main(String [] args)
{
for(int i =0; i<args.length; i++)
System.out.println(""+args[i]);
}
}
Ready to test this program with command line interface:
java HelloWorld a b c
We can see that this program prints thouse arguments after 'java Helloworld' a b c
It's a string array.
public class Test{
public static void main(String[] args){
System.out.println(args[0]);
}
}
$>javac Test.java
$>java Test hello
This will print: "hello"
Because "hello" is the argument you are passing to your class.
If you try: args[x], where x=0..n
and run your class via command line: java Test your arguments, then you will see any contents which you pass..