var = queue.isEmpty();
if(var=true) // this line *sets* var to true
{
    System.out.println("queue is empty");
}

If you change if (var=true) to if(var==true) or just if(var) you should see a different result

Answer from Patrick on Stack Overflow
🌐
Educative
educative.io › answers › what-is-queueisempty-in-java
What is queue.isempty() in Java?
The queue.isEmpty() function in Java is used to check if a queue is empty or not. queue.isEmpty() returns true if the queue is empty; otherwise, it returns false. The illustration below shows the visual representation of the queue.isEmpty() function.
🌐
Codecademy
codecademy.com › docs › java › queue › .isempty()
Java | Queue | .isEmpty() | Codecademy
August 7, 2025 - The .isEmpty() method is an inbuilt method of the Queue interface in Java that returns true if the queue contains no elements, and false otherwise. It is inherited from the Collection interface and provides a convenient way to check if a queue ...
🌐
PHP
php.net › manual › en › ds-queue.isempty.php
PHP: Ds\Queue::isEmpty - Manual
Function Reference · Other Basic Extensions · Data Structures · Ds\Queue · (PECL ds >= 1.0.0) Ds\Queue::isEmpty — Returns whether the queue is empty · public Ds\Queue::isEmpty(): bool · Returns whether the queue is empty.
🌐
Tabnine
tabnine.com › home page › code › java › java.util.queue
How to use isEmpty method in java.util.Queue - Code
List<SourceRecord> results = new ArrayList<>(); int record = 0; while (record < recordsPerBatch && !records.isEmpty()) { results.add(records.poll()); } return results; } // No longer running ... return null; } ... /** * Helper method to process the filter tree and get a map from column to a list of predicates applied to it. */ private Map<String, List<Predicate>> getPredicatesMap(@Nonnull FilterQueryTree rootFilterNode) { Map<String, List<Predicate>> predicatesMap = new HashMap<>(); Queue<FilterQueryTree> queue = new LinkedList<>(); queue.add(rootFilterNode); while (!queue.isEmpty()) { FilterQ
🌐
Educative
educative.io › answers › what-is-queueempty-in-cpp
What is queue.empty() in C++?
The queue.empty() function in C++ returns a true (1) value if the queue is empty. Otherwise, it returns false (0).
🌐
UAH
cs.uah.edu › ~rcoleman › Common › CodeVault › Code › Code130_Queue.html
A queue implemented as an array in C.
//-------------------------------------------- int isEmpty() { return (head == tail); } //-------------------------------------------- // Function: isFull() // Purpose: Return true if the queue is full. // Returns: TRUE if full, otherwise FALSE // Note: C has no boolean data type so we use // the defined int values for TRUE and FALSE // instead.
Find elsewhere
🌐
Cplusplus
cplusplus.com › reference › queue › queue › empty
std::queue::empty
Returns whether the queue is empty: i.e. whether its size is zero. This member function effectively calls member empty of the underlying container object. ... The example initializes the content of the queue to a sequence of numbers (form 1 to 10). It then pops the elements one by one until ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › concurrentlinkedqueue-isempty-method-in-java
ConcurrentLinkedQueue isEmpty() method in Java - GeeksforGeeks
November 26, 2018 - The isEmpty() method of ConcurrentLinkedQueue is used to check if this queue is empty or not. It returns true if ConcurrentLinkedQueue contains zero number of elements means if the ConcurrentLinkedQueue is empty.
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › queueempty-queuesize-c-stl
queue::empty() and queue::size() in C++ STL - GeeksforGeeks
June 4, 2023 - Queue is a type of container adaptor that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front. empty() function is used to check if the queue container is empty or not.
🌐
TutorialsPoint
tutorialspoint.com › queue-empty-and-queue-size-in-cplusplus-stl
queue::empty() and queue::size() in C++ STL
header file. queue::empty() is used to check whether the associated queue container is empty or not. This function returns either true or false, if the queue is empty (size is 0) then the function returns true, else if the queue is having some value then it will return false.
🌐
TutorialsPoint
tutorialspoint.com › home › data_structures_algorithms › queue data structure
Queue Data Structure
September 2, 2015 - MAX = 6; intArray = [0] * MAX front = 0; rear = -1; itemCount = 0; def isFull(): return itemCount == MAX def isEmpty(): return itemCount == 0 def removeData(): data = intArray[front+1] if(front == MAX): front = 0 itemCount-1 return data def insert(data): global rear, itemCount if(not isFull()): if(rear == MAX-1): rear = -1 rear = rear + 1 intArray[rear] = data itemCount+1 insert(3); insert(5); insert(9); insert(1); insert(12); insert(15); print("Queue: ") for i in range(MAX): print(intArray[i], end = " ") while(not isEmpty()): n = removeData() print(n, end = " ") Queue: 3 5 9 1 12 15 ·
🌐
GeeksforGeeks
geeksforgeeks.org › scala › scala-queue-isempty-method-with-example
Scala Queue isEmpty() method with example - GeeksforGeeks
October 29, 2019 - Method Definition: def isEmpty: Boolean Return Type: It returns true if the queue is empty or else it returns false.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › util › Queue.html
Queue (Java Platform SE 7 )
Queue implementations generally do not define element-based versions of methods equals and hashCode but instead inherit the identity based versions from class Object, because element-based equality is not always well-defined for queues with the same elements but different ordering properties. This interface is a member of the Java Collections Framework. ... Collection, LinkedList, PriorityQueue, LinkedBlockingQueue, BlockingQueue, ArrayBlockingQueue, LinkedBlockingQueue, PriorityBlockingQueue · addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
🌐
Old Dominion University
cs.odu.edu › ~zeil › cs361 › sum25 › Public › queues › index.html
Queues
skinparam style strictuml scale 0.75 hide empty members interface List<E> << interface >> interface Collection<E> << interface >> { isEmpty(): boolean; size(): int; } Collection <|.. List interface Iterable<T> << interface >> Iterable <|.. Collection interface Queue<E> << interface >> { add(E): boolean; element(): E; peek(): E; remove(): E; } Collection <|.. Queue class LinkedList<E> {} Queue <|.. LinkedList List <|.. LinkedList class PriorityQueue<E> Queue <|.. PriorityQueue · In Java, a Queue is an interface with a very limited set of functions, It is, however, a subclass of Collection, and so inherits a large number of functions that, in the spirit of being a queue, we very rarely use.
🌐
TutorialsPoint
tutorialspoint.com › home › cpp_standard_library › c++ queue empty function
C++ Queue Empty Function
July 15, 2015 - The C++ std::queue::empty() function is used to check whether the queue is empty or not and returns a boolean value, true if the queue is empty and does not contains any elements otherwise false.
🌐
Cppreference
en.cppreference.com › w › cpp › container › queue › empty
Cppreference
Checks if the underlying container has no elements. Equivalent to: return c.empty() · true if the underlying container is empty, false otherwise
🌐
Medium
tawhidshahrior.medium.com › queue-data-structure-42be46a7276b
Queue Data Structure. In this article, I will cover the major… | by Tawhid Shahrior | Medium
May 21, 2021 - isEmpty: Checks if the queue is empty · isFull: Checks if the queue is full · display: Additional function to display the contents in the queue · Generally used in cases where we need to manage a group of data based on their order of arrival.