import java.lang.reflect.Array;
/*********************************************************************
* Array manipulation for Java 1.1+.
*
*
* Java 1.1 compatible.
*
*
* @see
* ArrayLib2
*
* @version
* 2003-04-07
* @since
* 2001-04-06
* @author
* David Wallace Croft*/
public class Util{
/*********************************************************************
* Prepends an Object to an Object array.
*
*
* Example:
*
*
* String [ ] stringArray
* = ( String [ ] ) ArrayLib.prepend ( new String [ ] { }, "" );
*
*
*
*
* @throws NullArgumentException
*
* If either argument is null.
*
* @return
*
* Returns a new array with the same component type as the old array.
*********************************************************************/
public static Object [ ] prepend ( Object [ ] oldArray, Object o )
//////////////////////////////////////////////////////////////////////
{
Object [ ] newArray = ( Object [ ] ) Array.newInstance (
oldArray.getClass ( ).getComponentType ( ), oldArray.length + 1 );
System.arraycopy ( oldArray, 0, newArray, 1, oldArray.length );
newArray [ 0 ] = o;
return newArray;
}
}