The size() method of AbstractSet in Java is used to get the size for this instance of the AbstractSet. It returns an integer value which is the size for this instance of the AbstractSet.
public int size()
Parameters: This function has no parameters.
Returns: The method returns an integer value which is the size for this instance of the AbstractSet.
Below examples illustrates the AbstractSet.size() method:
AbstractSet: [1, 2, 3, 4] Size: 4
AbstractSet: [For, ForGeeks, Geeks, GeeksForGeeks] Size: 4
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.