Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>[Ljava.lang.Object;</code> is the name for <code>Object[].class</code>, the <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Class.html" rel="noreferrer"><code>java.lang.Class</code></a> representing the class of array of <code>Object</code>.</p> <p>The naming scheme is documented in <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29" rel="noreferrer"><code>Class.getName()</code></a>:</p> <blockquote> <p>If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java Language Specification (<a href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.1" rel="noreferrer">§13.1</a>).</p> <p>If this class object represents a primitive type or <code>void</code>, then the name returned is the Java language keyword corresponding to the primitive type or <code>void</code>. </p> <p>If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more <code>'['</code> characters representing the depth of the array nesting. The encoding of element type names is as follows:</p> <pre><code>Element Type Encoding boolean Z byte B char C double D float F int I long J short S class or interface Lclassname; </code></pre> </blockquote> <p>Yours is the last on that list. Here are some examples:</p> <pre><code>// xxxxx varies System.out.println(new int[0][0][7]); // [[[I@xxxxx System.out.println(new String[4][2]); // [[Ljava.lang.String;@xxxxx System.out.println(new boolean[256]); // [Z@xxxxx </code></pre> <p>The reason why the <code>toString()</code> method on arrays returns <code>String</code> in this format is because arrays do not <code>@Override</code> the method inherited from <code>Object</code>, which is specified as follows:</p> <blockquote> <p>The <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#toString%28%29" rel="noreferrer"><code>toString</code> method for class <code>Object</code></a> returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:</p> <pre><code> getClass().getName() + '@' + Integer.toHexString(hashCode()) </code></pre> </blockquote> <p><strong><em>Note</em></strong>: you can not rely on the <code>toString()</code> of any arbitrary object to follow the above specification, since they can (and usually do) <code>@Override</code> it to return something else. The more reliable way of inspecting the type of an arbitrary object is to invoke <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Object.html#getClass%28%29" rel="noreferrer"><code>getClass()</code></a> on it (a <code>final</code> method inherited from <code>Object</code>) and then <a href="http://java.sun.com/developer/technicalArticles/ALT/Reflection/index.html" rel="noreferrer">reflecting</a> on the returned <code>Class</code> object. Ideally, though, the API should've been designed such that reflection is not necessary (see <em>Effective Java 2nd Edition, Item 53: Prefer interfaces to reflection</em>).</p> <hr> <h3>On a more "useful" <code>toString</code> for arrays</h3> <p><a href="http://download.oracle.com/javase/6/docs/api/java/util/Arrays.html" rel="noreferrer"><code>java.util.Arrays</code></a> provides <code>toString</code> overloads for primitive arrays and <code>Object[]</code>. There is also <code>deepToString</code> that you may want to use for nested arrays.</p> <p>Here are some examples:</p> <pre><code> int[] nums = { 1, 2, 3 }; System.out.println(nums); // [I@xxxxx System.out.println(Arrays.toString(nums)); // [1, 2, 3] int[][] table = { { 1, }, { 2, 3, }, { 4, 5, 6, }, }; System.out.println(Arrays.toString(table)); // [[I@xxxxx, [I@yyyyy, [I@zzzzz] System.out.println(Arrays.deepToString(table)); // [[1], [2, 3], [4, 5, 6]] </code></pre> <p>There are also <code>Arrays.equals</code> and <code>Arrays.deepEquals</code> that perform array equality comparison by their elements, among many other array-related utility methods.</p> <h3>Related questions</h3> <ul> <li><a href="https://stackoverflow.com/questions/2721033/java-arrays-equals-returns-false-for-two-dimensional-arrays">Java Arrays.equals() returns false for two dimensional arrays.</a> -- in-depth coverage</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload