Java Queue | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Java Queue

If Queue is implemented by Linked List, what is the return type of offer() method ? Or void ?

25th Feb 2020, 7:27 PM
Yijun Sun
Yijun Sun - avatar
2 Answers
0
The latter form of the insert operation is designed specifically for use with capacity-restricted Queue implementations; in most implementations, insert operations cannot fail. For example when Queue is implemented by array, size > capacity, return false.
25th Feb 2020, 7:32 PM
Yijun Sun
Yijun Sun - avatar
0
You can easily look this up in the java docs. https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Queue.html#offer(E) offer() returns a boolean that is true if the element was added successfully.
25th Feb 2020, 7:37 PM
Tibor Santa
Tibor Santa - avatar