8.3 Aggregate Array Operations
Once the array is declared and instantiated, it would be convenient if we could just use the array name to perform operations on the whole array, such as printing the array, copying the array to another array, inputting values to the array, and so on. Unfortunately, Java does not support these aggregate operations on arrays.
For example, attempting to print the array using the array name will not print all the elements of the array. Instead, this statement:
System.out.println( cellBills ); // incorrect attempt to print array!
calls the toString method of the Array class, which simply prints the name of the object’s class and the hash code of the array name, for example, [D@310d42.
8.3.1 Printing Array Elements ...
Get Java Illuminated, 5th 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.