aspose file tools*
The moose likes Beginning Java and the fly likes Output of 'args' gives some wierd info...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Output of Watch "Output of New topic
Author

Output of 'args' gives some wierd info...?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
when i give
System.out.println(args);//ToArgs is the name of the prog.
in my code i get some wierd results during my interpretation.....
ie. the compile works fine....the interpretation gives me....
d:\>java ToArgs
[Ljava.lang.String;@273dc3
does any one know what that output means?
good luck,
ak.
Thandapani Saravanan
Ranch Hand

Joined: Oct 17, 1999
Posts: 117
Remember the argument to main method is an array of Strings. When you try print an array as such, that is output you get. (it calls Object's toString())
If you want to print all entries try printing them one by one:
for(int i=0;i<args.length;i++)>
System.out.println(args[i]);


Saravanan
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
Ljava.lang.String;@273dc3

The @273dc3 is the address of the array args[].
Marilyn

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
What if i want to put a condition check on the args. passed.
ie. Say if a persson passes arguments then print them else say no args. passed
eg.
if (args==true)
print(args[0], args[1]); etc.
else print(No args passed);
something likethe pseudocode eg. shown above.
ak.
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 582
    
    7

you could try something like:
<pre>class TestArgs {
public static void main ( String[] args ) {

if ( args.length > 0 ) {
for ( int i = 0; i < args.length; i++ ) {
System.out.println( args[i] );
}
} else {
System.out.println("No arguments");
}
}
}
</pre>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Output of 'args' gives some wierd info...?