+ 1
JAVA static main default array argument
Why I cant see anything out of this ? public class test_deep { public static void main(String[] args) { for(String s:args) { System.out.println(s); } } }
2 Respostas
+ 1
Really never think about this but this is what I find
It outputs:
[Ljava.lang.String;@153c375
That's Java's default toString return value for String[] (an array of String). The [ means "array", the L means "class or interface", and java.lang.String is self-explanatory. That part comes from. The ;@153c375 is ;@ followed by the hashCode of the array as a hex string.
(I think the default implementation of hashCode for Object indicates where in memory the array is located, which is why it's different for different invocations of your program, but that's unspecified behavior and wouldn't be any use to you anyway.)
Source: https://stackoverflow.com/q/5959579/9973584
+ 1
In order to see the output, you need to pass command-line argument.
You will understand command-line arguments if you will use command prompt to run java program.
(I assume you are working on windows)
step 1)open the command prompt
step 2)navigate to the folder where your .java file is present
step 3)compile using the command `javac test_deep.java`
step 4)run java program using the command `java test_deep hello world!!`
Here I have passed to command-line arguments hello and world!!