| Author |
Array.newInstance documentation
|
Luigi Plinge
Ranch Hand
Joined: Jan 06, 2011
Posts: 441
|
|
Does the example they give make any sense to you guys? The first line seems to create an array with one element of value length, then this array is passed in where an int should be?
newInstance
public static Object newInstance(Class<?> componentType, int length)
throws NegativeArraySizeException
Creates a new array with the specified component type and length. Invoking this method is equivalent to creating an array as follows:
int[] x = {length};
Array.newInstance(componentType, x);
Parameters:
componentType - the Class object representing the component type of the new array
length- the length of the new array
Returns:
the new array
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16817
|
|
Read this part again....
Invoking this method is equivalent to creating an array as follows:
In this case, the "equivalent" being referred to is an overloaded method -- a method that allows you to declare a multidimensional array. What the example is, is what this method does. It is not an example of how to use this method.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: Array.newInstance documentation
|
|
|