0

Here

set s = new HashSet();

Here what does the new operator does exactly. Is that creates the object for the class Set or for the object for the constructors class HashSet. why we want to write these types of codes. and is that any alternative option to create a object for a class without using new keyword.

Please explain me clearly i am new to java programming...

4

1 回答 1

0

“new”创建类“HashSet”的新“实例”。

“创建”的一部分是调用类的构造函数。

在 Java 中(与其他语言不同,例如 C++ 或 Javascript),“new”是创建新对象的唯一方法。

这里有更多信息:

于 2012-06-19T16:35:29.370 回答