I have the following example:
import java.util.EnumSet;
import java.util.Iterator;
public class SizeSet {
public static void main(String[] args) {
EnumSet largeSize = EnumSet.of(Size.XL,Size.XXL,Size.XXXL);
for(Iterator it = largeSize.iterator();it.hasNext();){
Size size = (Size)it.next();
System.out.println(size);
}
}
}
enum Size {
S, M, L, XL, XXL, XXXL;
}
In this code I can understand that the Enum creates an Enum type of Sizes.
My question is: is largeSize an object of EnumSet type? What does it really mean? I really want to understand it better.

As for any variable, its type is found in its declaration:
So yes,
largeSize(which should be namedlargeSizessince it's a collection) is of typeEnumSet. It should also be generified, and thus be declared asWhat it means, is that
largeSizesis of typeEnumSet. AnEnumSetis aSetwhich contains enum instance of a specific enum type, in a more efficient way than otherSetimplementations (likeHashSet,TreeSet, etc.). To know what anEnumSetis, read its API.