- Q A person can move the Supreme Court directly in the event of violation of Fundamental Rights under:
- Q How is persistence implemented in enterprise beans?
- Q What Are Other Inline Elements?
- Q Explain the Ganga and Yamuna action plan
- Q What are the different job scheduling in operating systems?
- Q Whats the ultimate cake topping?
- Q Who was the grandson of Charles Martel?
- Q What is the difference between a trace value and trace parameters?
- Q What does hours d'oeurve literally mean
- Q Tell me does one have to stop other medicines which the patient has been taking?
- Q Why is it that in some developing countries slum settlements have sprung up near high-rise buildings/wealthier neighbourhoods?
Question
What are the differences between Queue and Stack in java?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
Answers
A collection designed for holding elements prior to processing.
Besides basic Collection operations, queues provide additional insertion, extraction, and inspection operations.
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner.
Stack is also a form of Queue but one difference, it is LIFO (last-in-first-out).
Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). Also note that Stack and Vector are both synchronized.
Usage:
Use a queue if you want to process a stream of incoming items in the order that they are received.Good for work lists and handling requests.
Use a stack if you want to push and pop from the top of the stack only. Good for recursive algorithms. Your Comment
Besides basic Collection operations, queues provide additional insertion, extraction, and inspection operations.
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner.
Stack is also a form of Queue but one difference, it is LIFO (last-in-first-out).
Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). Also note that Stack and Vector are both synchronized.
Usage:
Use a queue if you want to process a stream of incoming items in the order that they are received.Good for work lists and handling requests.
Use a stack if you want to push and pop from the top of the stack only. Good for recursive algorithms. Your Comment
- 0
- 0
- New Answer
- Contributors: *,
More Software,Java Questions..
What is the inputsplit in map reduce software?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Can variables be used in Java without initialization?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Java,
What is the difference between java bean and enterprise java bean?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Java,
What is software configuration management?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How does the java database connectivity (jdbc) work?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Java,
What are the advantages of threads in java?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 0 )
- Tags: Java,
What Is Java Api For Xml-based Rpc (jax-rpc)?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
How can you implement fine-grained auditing?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is IBM’s simple explanation for Big Data’s four critical features?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is static synchronized method in JDBC API? Give an example?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
What does the NULLIF function do?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What happens if a start method is not invoked and the run method is directly invoked?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Should we override finalize method
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
what is the difference between mysql_fetch_array and mysql_fetch_object?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How will XML affect my document links?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What is object cloning in Java?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 0 )
- Tags: Java,
Why to use Style Sheets?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
What are Filters in MVC?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
Can you explain Application layer in OSI model?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,
How to define new testplan attributes?
- 0
- 0 |
- |
- Post Answer |
- Answers ( 1 )
- Tags: Software,