Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using the <code>[[[Ljava.lang.String;</code> notation is the standard way of representing array class names. </p> <p>The XMLEncoder and XMLDecoder use standard Java functionality to write and read arrays:</p> <pre><code>String[][][] foo = new String[3][4][5]; foo[0][0][0] = "a"; foo[2][3][4] = "z"; XMLEncoder encoder = new XMLEncoder(System.out); encoder.writeObject(foo); encoder.flush(); encoder.close(); </code></pre> <p>yields the following result:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;java version="1.6.0_22" class="java.beans.XMLDecoder"&gt; &lt;array class="[[Ljava.lang.String;" length="3"&gt; &lt;void index="0"&gt; &lt;array class="[Ljava.lang.String;" length="4"&gt; &lt;void index="0"&gt; &lt;array class="java.lang.String" length="5"&gt; &lt;void index="0"&gt; &lt;string&gt;a&lt;/string&gt; ... </code></pre> <p>I currently don't see any problem in using Class.forName() with a self-built class name (e.g. prepending the <code>[L</code>, since it's also used by the Java standard classes in the same way. </p> <pre><code>Class arrayClass = Class.forName("[L" + "java.lang.String" + ";"); </code></pre> <p>And as the <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#forName%28java.lang.String,%20boolean,%20java.lang.ClassLoader%29" rel="nofollow">JavaDoc for Class.forName</a> describes, the class is loaded but not initialized, and you also don't need to create an instance for it.</p> <blockquote> <p>If <code>name</code> denotes an array class, the component type of the array class is loaded but not initialized.</p> </blockquote> <p>Your last remark about various blog posts where this would not work would be interesting to investigate.</p>
 

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