Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's meant by a class name being a plural in Java, such as "Collections"?

I've encountered some class names being plural in Java, such as Collections (not to be confused with Collection), and Package java.util lists a couple of others in that package alone, such as Arrays and Objects.

In general, what's meant by a class name being plural? Does it always mean that it's a set of utility static methods, like with Collections?

like image 691
Andrew Grimm Avatar asked Oct 27 '25 22:10

Andrew Grimm


1 Answers

There are several classes in java that are plural despite them not being utilities. These include DoubleSummaryStatistics and IntSummaryStatistics.java. I think the primary meaning is "Does making this class plural improve the understanding of the class or make it more readable?" DoubleSummaryStatistic would likely be non representative of the class itself. The majority of plural classes are utilities or constants. The other, are sometimes extensions of a HashMap for properties or attributes. From java.util, the following classes are plural:

LongSummaryStatistics.java - public class 
Attributes.java - public class
IntSummaryStatistics.java - public class
Properties.java - public class 
DoubleSummaryStatistics.java - public class

Executors.java - Utility
Helpers.java - Utility
ArrayPrefixHelpers.java - Utility
Spliterators.java - Utility
ZipUtils.java - Utility
Comparators.java - Utility
ArraysParallelSortHelpers.java - Utility
Collections.java - Utility
Collectors.java - Utility
Streams.java - Utility
SortedOps.java - Utility
FindOps.java - Utility
ReduceOps.java - Utility
WhileOps.java - Utility
DistinctOps.java - Utility
StreamSpliterators.java - Utility
ForEachOps.java - Utility
Nodes.java - Utility
SliceOps.java - Utility
MatchOps.java - Utility
Objects.java - Utility
Arrays.java - Utility

FormattableFlags.java - Constants
CharPredicates.java - Constants 
ZipConstants.java - Constants
like image 80
Edward Jezisek Avatar answered Oct 30 '25 11:10

Edward Jezisek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!