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

  • Home
  • SEARCH
  • 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 8919553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:03:37+00:00 2026-06-15T06:03:37+00:00

If I have a PriorityQueue made up of T objects, and T has a

  • 0

If I have a PriorityQueue made up of T objects, and T has a compareTo() method and implements comparable, but my PriorityQueue also takes a comparator as a parameter, what is my PriorityQueue going to look to for the ordering of its elements?

In other words, which one determines the priority of the objects? The compareTo() method or the provided comparator?

  • 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-15T06:03:38+00:00Added an answer on June 15, 2026 at 6:03 am

    The documentation for the comparator parameter of the constructor states that

    comparator – the comparator used to order this priority queue. If null then the order depends on the elements’ natural ordering.

    This means that when a comparator is specified, the natural ordering established by the compareTo method is ignored.

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

Sidebar

Related Questions

I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but
I'm trying to use a PriorityQueue to order objects using a Comparator . This
I have a PriorityQueue containing references to some objects. When I initially insert the
I have a PriorityQueue that contains objects of type box, which is my own
I currently have a method that uses a scala.collection.mutable.PriorityQueue to combine elements in a
Say I have a java PriorityQueue (which java implements as a heap) that I
I have a couple of functions whose only parameter requirement is that it has
I have a PriorityQueue that has an element with a priority. Now I want
I am implementing a PriorityQueue in my program. For that I have also implemented
I need B class to have a min priority queue of AToTime objects. AToTime

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.