Различие между набором Java и [закрытыми] наборами

using System.IO; 

string path = @"c:\folders\newfolder"; // or whatever 
if (!Directory.Exists(path)) 
{ 
DirectoryInfo di = Directory.CreateDirectory(path); 
di.Attributes = FileAttributes.Directory | FileAttributes.Hidden; 
}
55
задан Jonathan Lam 15 November 2015 в 14:41
поделиться

4 ответа

Collection is a base interface for most collection classes, whereas Collections is a utility class. I recommend you read the documentation.

76
ответ дан 26 November 2019 в 17:43
поделиться

collection : A collection(with small 'c') represents a group of objects/elements.

Collection : The root interface of Java Collections Framework.

Collections : A utility class that is a member of the Java Collections Framework.

17
ответ дан 26 November 2019 в 17:43
поделиться

Are you asking about the Collections class versus the classes which implement the Collection interface?

If so, the Collections class is a utility class having static methods for doing operations on objects of classes which implement the Collection interface. For example, Collections has methods for finding the max element in a Collection.

The Collection interface defines methods common to structures which hold other objects. List and Set are subinterfaces of Collection, and ArrayList and HashSet are examples of concrete collections.

24
ответ дан 26 November 2019 в 17:43
поделиться

Collection, as its javadoc says is "The root interface in the collection hierarchy." This means that every single class implementing Collection in any form is part of the Java Collections Framework.

The Collections Framework is Java's native implementation of data structure classes (with implementation specific properties) which represent a group of objects which are somehow related to each other and thus can be called a collection.

Collections is merely an utility method class for doing certain operations, for example adding thread safety to your ArrayList instance by doing this:

List<MyObj> list = Collections.synchronizedList(new Arraylist<MyObj>());

The main difference in my opinion is that Collection is base interface which you may use in your code as a type for object (although I wouldn't directly recommend that) while Collections just provides useful operations for handling the collections.

13
ответ дан 26 November 2019 в 17:43
поделиться
Другие вопросы по тегам:

Похожие вопросы: