Array Utilities

The java.util package focuses on supporting the collections framework classes, but the simple array is not overlooked either. The Arrays class provides a number of static methods useful in manipulating arrays just as the Collections class supports the more sophisticated containers.

The Arrays Class

The Arrays class consists solely of static methods that operate on an array, or compare two arrays for equality. Nearly all the methods are for searching, comparing, filling, or sorting an array. The one exception is the asList method, which provides a List view of an underlying array:

public static List asList(Object[] a)

You can iterate an array using the reference returned by asList and even modify the array through the List methods ...

Get Special Edition Using Java 2 Standard Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.