jaggregate
Class Arrays

java.lang.Object
  extended by jaggregate.Arrays

public class Arrays
extends Object

Utility class containing methods that work with arrays.

Version:
$Id: Arrays.java,v 1.3 2008/03/30 03:07:10 pholser Exp $
Author:
Paul Holser

Method Summary
static
<E> E[]
arrayWith(E... items)
          Creates and answers an array containing the given items.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

arrayWith

public static <E> E[] arrayWith(E... items)
Creates and answers an array containing the given items.

This is a more expressive, less repetitive way to create arrays. For example:


   Integer[] littlePrimes = arrayWith( 2, 3, 5, 7 );
 
versus

   Integer[] littlePrimes = new Integer[] { 2, 3, 5, 7 };
 

Type Parameters:
E - the type of the items
Parameters:
items - a variable-length list of items
Returns:
the items as an array
Throws:
NullPointerException - if the varargs list is null
IllegalArgumentException - if the varargs list is of length zero
See Also:
Java 5 syntax tricks to keep you DRY


© Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. Licensed under the Academic Free License version 3.0. pholser@alumni.rice.edu