• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array name-mangling?  RSS feed

 
Jagan Nambi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Please refer the following code:


When I compile and run it, I consistently get the following output "[I@187aeca". Is this the C++ equivalent of array name-mangling?

Thanks in advance.

Regards,
Jags.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really. It's just what the "toString()" method of java.lang.Object will return. That method returns the name of the class, an "@", and the return value of calling hashCode() on that same object, in hexadecimal.

The "[I" part is the name of the class; it's a JVM type descriptor. "[" means "array", and "I" means "int". "[[Ljava.lang.String;" is the name of a 2-dimensional array of Strings.

Many classes will override toString() to return something less ugly and more meaningful.
 
Jagan Nambi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!! Had totally forgotten about toString() returning that string.

And am I right in stating that since I'm using an array of a primitive data type (int), there's no way to make it return something more meaningful than what the JVM would provide?
[ July 23, 2007: Message edited by: Jagan Nambi ]
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out:
)]Arrays.toString(int[])
[ July 23, 2007: Message edited by: Garrett Rowe ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, there's no way to change it. Garrett's link to java.util.Arrays.toString(int[]) is a useful one.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!