Can an object array be regarded as a collection of objects in Java?

The collection definition of Oracle site is:

A collection — sometimes called a container — is simply an object that groups multiple 
elements into a single unit.

I know Java provides Java util. Collection. It includes set, ArrayList, queue, etc

My question is: would I be wrong if I took an array of objects as a collection of objects? (although java.util.collection may not contain an array)

Editor: I found something interesting This is how Microsoft defines arrays and Collections: http://msdn.microsoft.com/en-sg/library/9ct4ey7x (v=vs.90). aspx

Solution

This is a bit like a semantic problem The word "set" in English may mean "more than one", so, yes, an array is a set However, in Java, you usually spell it collection, which contains the capital letter C, that is, Java util. Object of collection subtype In this regard, you cannot use arrays because arrays in java do not implement this interface

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>