June 2025
Intermediate to advanced
1129 pages
53h
English
The java.util.Arrays class declares useful static methods for dealing with arrays, including options for comparing, sorting, and filling arrays, as well as conducting binary searches.
Let’s say we have a string array we want to output to the screen for debugging purposes.
String[] names = { "Butterfinger", "Dickmanns", "Fruitella", "Nutbar"};
Listing 4.12 CandyNamesArraysToString, main()
An output with System.out.println(names) is out of the question because toString() is not meaningfully defined on the array object type. The static method Arrays.toString(...) returns the desired string representation of the array for ...
Read now
Unlock full access