• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Vargs in place of String array as argument to main() method please explain output  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)public class ProgramArgument {

2) public ProgramArgument() { System.out.println(this); }

3) public static void main(String...args) {

4) new ProgramArgument();

5) System.out.println(args);
6) }
7) }
/* I obtain output
ProgramArgument@3e25a5
[Ljava.lang.String;@19821f

when i make comment the 4th statement I obtain output
[Ljava.lang.String;@3e25a5

Can anyone explain why this output and what's the reason of this output.....
Thanks */

 
Sheriff
Posts: 21423
94
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Ljava.lang.String;@3e25a5

The first [ always means it's an array. Next comes the type; I for int, B for byte, Z for boolean and L<class name>; for classes. So in this case, the [Ljava.lang.String; indicates it's a String array.
The part after the @ is the hexidecimal representation of the hash code.
 
Marshal
Posts: 59745
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

As well as what Rob told you, have a look at the Object class and its un-overridden toString() method.
 
Nishant Arora
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks dear
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!