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:
parent
3ed85bb87d
commit
b9c088ac8d
|
@ -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 <T> T[] createAnArray(int size)
|
||||
{
|
||||
public static <T> T[] createAnArray(int size) {
|
||||
return T[size]; // compiler error here
|
||||
}
|
||||
public static <T> T[] createAnArray(int size)
|
||||
{
|
||||
return (T[])Object[size]; // ClassCastException at runtime
|
||||
public static <T> 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.<Number>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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue