Open In App

ConcurrentLinkedQueue size() method in Java

Last Updated : 26 Nov, 2018
Comments
Improve
Suggest changes
40 Likes
Like
Report
The size() method of ConcurrentLinkedQueue is used to returns number of elements that this ConcurrentLinkedQueue contains. Syntax:
public int size()
Returns: This method number of elements in this ConcurrentLinkedQueue. Below programs illustrate size() method of ConcurrentLinkedQueue: Example 1:
Output:
ConcurrentLinkedQueue: [4353, 7824, 78249, 8724]
Size of ConcurrentLinkedQueue: 4
Example 2:
Output:
ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi]
Size of ConcurrentLinkedQueue: 4

After 2 removal of elements

ConcurrentLinkedQueue: [Sanjeet, Rabi]
Size of ConcurrentLinkedQueue: 2
Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html#size--

Similar Reads