add()

Which to prefer add() or offer() to add items in Java Queue?

Both java queue add () and offer () methods are available in the Queue interface and are used to add elements to the queue. Preference will be given to queue’s Offer() method. The add() method internally just call the offer() method and does nothing extra. And also, the add () method throws exception “java.lang.IllegalStateException: Queue […]

Scroll to top