• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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: 21465
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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: 61766
193
  • 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!