Video For Finding Size Of A Queue Is Not There. Can You Tell How To Find The Size Of A Queue?
Finding Size Of A Given Queue
You can read the number of elements stored in a Java Queue via its size()
method. Here is an example of obtaining the size of a Java Queue via its size()
method:
Queue queue = new LinkedList<>(); queue.add(“element 1”); queue.add(“element 2”); queue.add(“element 3”); int size = queue.size();
After running this code the size
variable should contain the value 3 - because the Queue contains 3 elements at the time size()
is called.