Java Collection size() methodLast Updated : 17 Mar 2025 The size() method of Java Collection Interface returns the total count of the elements contained in this collection. SyntaxParametersNA Return ValueThe size() method returns the total count of the elements present in this collection. Example 1Output: The elements in Collection : [34, 12, 45] Size of the collection 3 Example 2Output: Total alphabets : 26 collection : [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z] Number of vowels : 5 Vowels : [a, e, i, o, u] Example 3Output: The queue is empty. Next TopicJava-Collection |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India