Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.HashSet; public interface JavaCollectionSizeExample1 { public static void main(String[] args) { Collection
collection = new HashSet<>(); //add integer values in this collection collection.add(34); collection.add(12); collection.add(45); System.out.print("The elements in Collection : "); System.out.println(collection); //returns the size of the collection System.out.println("Size of the collection "+collection.size()); } }
Output