Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9173129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:31:02+00:00 2026-06-17T16:31:02+00:00

Queue In Java provides FIFO data structure. Per what I learned, queues have some

  • 0

Queue In Java provides FIFO data structure. Per what I learned, queues have some responsibility to adhere to first-in-first-out behavior. In other terms, you may not remove items from the middle of the queue. However, in Java we can remove random queue elements by using an iterator.

Is this a bad design encapsulation-vise? or is the queue data structure supposed to allow this?

Queue<String> queue = new LinkedList<String>();
queue.add("e1");
queue.add("e2");
queue.add("e3");
queue.add("e4");

queue.remove("e3");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:31:03+00:00Added an answer on June 17, 2026 at 4:31 pm

    Queue obviously inherits some of this added functionality by being part of the Collection hierarchy. From a polymorphic standpoint, it is beneficial to have Queue act like any other Collection as it increases the portability of the data structure.

    From a design perspective, I wouldn’t say it’s bad necessarily. Imagine a queue/line at a grocery store. There are situations where a customer might need to be removed from the middle of the line. This particular implementation of a queue supports that, which can be useful.

    While you could argue that the additional methods could let you shoot yourself in the foot, you could easily create an implementation of Queue that doesn’t allow things like remove(Object) or iterator.remove() if you wanted a strict Queue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The queue, or FIFO, is one of the most common data structures, and have
I need a Max-Priority Queue data structure. Looking in Java's Priority Queue I noticed
What C++ library provides Data structures API that match the ones provided by java.util.*
is there a fifo queue implementation that provides for replacing the head element after
For my Java application, I need some method that finds out if item1 is
I have several queues that all extend a Queue class. I want to do
I am looking for a fast queue implementation in Java. I see that LinkedList
Standard Java does not offer an object implementing the Queue interface on top of
I'm working on a GAE/Java app, and today I read about using app.yaml, queue.yaml,
Our Java app writes to MQ Series queues via a Weblogic JMS Message Bridge.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.