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 1055077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:30:24+00:00 2026-05-16T17:30:24+00:00

I need a priority queue of objects but I keep getting this error: symbol:

  • 0

I need a priority queue of objects but I keep getting this error:

symbol: constructor PriorityQueue(anonymous java.util.Comparator<map.Node>>)
location: class java.util.PriorityQueue<map.Node>
  PriorityQueue<Node> pq = new PriorityQueue<Node>(new Comparator<Node>() 

Here an excerpt from my code:

public class map {

 static class Node {
  Node parent;
  State state;
  private int cost;
  public Node() {};
  public Node(Node parent_passed, State state_passed, Integer cost_passed ) { 
  this.parent = parent_passed; 
  this.state = state_passed;
  this.cost = cost_passed;
  }
  public int getCost()
  {
   return cost;
  }

  }

 public static void main(String[] args) 
 {
  PriorityQueue<Node> pq = new PriorityQueue<Node>(new Comparator<Node>() 
  {
   public int compare(Node a1, Node a2) {
    return a2.getCost() - a1.getCost(); 
   }
  });


 }

Any ideas? Do I need to make the Node class public and put it in it’s own file?

  • 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-05-16T17:30:25+00:00Added an answer on May 16, 2026 at 5:30 pm

    You trying to use a constructor that doesn’t exist to create the PriorityQueue object. There is no PriorityQueue(Comparator) constructor defined in the JavaDoc (http://download.oracle.com/javase/6/docs/api/java/util/PriorityQueue.html). It does have one that takes an int for initialCapacity and a comparator, you might want to try that.

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

Sidebar

Related Questions

I need B class to have a min priority queue of AToTime objects. AToTime
I need a Max-Priority Queue data structure. Looking in Java's Priority Queue I noticed
I need to store objects in a heap/priority queue. However, the objects may change
I need a priority queue where I can increase or decrease the priority key.
I need some kind of priority queue to store pairs <key, value> . Values
I need to implement a priority queue in C programming using singly linked list.
I'm trying to understand this C code from a simple priority queue, especially -
I need to use a priority queue in my Python code, and: am looking
so I am having trouble implementing priority queue. For a priority queue, I need
I need a priority queue, I guess in the framework, CHMutableArrayHeap and CHBinaryHeap can

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.