java.util
Class Arrays

java.lang.Object
  extended by java.util.Arrays

public class Arrays
extends Object

This class contains various static utility methods performing operations on arrays, and a method to provide a List "view" of an array to facilitate using arrays with Collection-based APIs. All methods throw a NullPointerException if the parameter array is null.

Implementations may use their own algorithms, but must obey the general properties; for example, the sort must be stable and n*log(n) complexity. Sun's implementation of sort, and therefore ours, is a tuned quicksort, adapted from Jon L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function", Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November 1993). This algorithm offers n*log(n) performance on many data sets that cause other quicksorts to degrade to quadratic performance.

Since:
1.2
See Also:
Comparable, Comparator

Method Summary
static void fill(Object[] a, int fromIndex, int toIndex, Object val)
          Fill a range of an array with an Object value.
static void fill(Object[] a, Object val)
          Fill an array with an Object value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fill

public static void fill(Object[] a,
                        Object val)
Fill an array with an Object value.

Parameters:
a - the array to fill
val - the value to fill it with
Throws:
ClassCastException - if val is not an instance of the element type of a.

fill

public static void fill(Object[] a,
                        int fromIndex,
                        int toIndex,
                        Object val)
Fill a range of an array with an Object value.

Parameters:
a - the array to fill
fromIndex - the index to fill from, inclusive
toIndex - the index to fill to, exclusive
val - the value to fill with
Throws:
ClassCastException - if val is not an instance of the element type of a.
IllegalArgumentException - if fromIndex > toIndex
ArrayIndexOutOfBoundsException - if fromIndex < 0 || toIndex > a.length