In Java, you import HashMap;
and import ArrayList;
, etc. So why is import Arrays;
plural?
The Utility classes which deals with Arrays
, Files
, Paths
, Objects
or Collections
are plural. Exactly because they are not an Array or a Collection but rather a number of utility functions to work on them. You can even see that in the Javadoc intro:
This class contains various methods for manipulating arrays
Some of those classes are fairly new additions in 1.7. So this explains their common naming convention. I am not sure if there is a written conventions for it, but it is surely a practical one.
Because it's a collection of utilities to work with arrays. The other examples you've mentioned are actually instances of a particular type of collection.
For example, the same naming convention has been followed in Guava for Lists, Sets, Maps etc.
It is a collection of utilities that deals with arrays, and doesn't represent the array itself. Also there is another class with name Array
. Check this https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Array.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With