Fix missing new in example. Fix javadoc. Fix code style.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1076703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joerg Schaible 2011-03-03 17:48:24 +00:00
parent 3ed85bb87d
commit b9c088ac8d
1 changed files with 5 additions and 8 deletions

View File

@ -257,13 +257,11 @@ public class ArrayUtils {
* <p>Arrays are covariant i.e. they cannot be created from a generic type:</p>
*
* <pre>
public static &lt;T&gt; T[] createAnArray(int size)
{
public static &lt;T&gt; T[] createAnArray(int size) {
return T[size]; // compiler error here
}
public static &lt;T&gt; T[] createAnArray(int size)
{
return (T[])Object[size]; // ClassCastException at runtime
public static &lt;T&gt; T[] createAnArray(int size) {
return (T[])new Object[size]; // ClassCastException at runtime
}
* </pre>
*
@ -280,7 +278,7 @@ public class ArrayUtils {
*
* Note, this method makes only sense to provide arguments of the same type so that the
* compiler can deduce the type of the array itself. While it is possible to select the
* type explicitly like in <code>Number[] array = ArrayUtils.<Number>toArray(new
* type explicitly like in <code>Number[] array = ArrayUtils.&lt;Number&gt;toArray(new
* Integer(42), new Double(Math.PI))</code>, there is no real advantage to <code>new
* Number[] {new Integer(42), new Double(Math.PI)}</code> anymore.
*
@ -289,8 +287,7 @@ public class ArrayUtils {
* @return the array
* @since 3.0
*/
public static <T> T[] toArray(final T... items)
{
public static <T> T[] toArray(final T... items) {
return items;
}