Arrays
Arrays are part of the collections framework. There are some static methods that can be used to manipulate arrays. The operations you can perform are creating, sorting, searching, comparing, streaming, and transforming arrays. You were introduced to arrays in Chapter 2, Learning the Basics, where you saw how they can be used to store data of the same type. The declaration of an array is quite straightforward. Let's see what an array of strings would look like:
String[] text = new String[] { "spam", "more", "buy" };
Running operations on an array is as easy as calling some of the methods contained in the java.util.Arrays
package. For example, sorting the previous array would require calling the following:
java.util.Arrays.sort( text );
The methods dedicated to handling arrays include one method that could be used to print out full arrays as if they were strings. This can be very handy when debugging a program:
System.out.println...