0

I want to store all long type integer to a priority queue, and I want to intialize the queue something like this

PriorityQueue<long> pQueue = new PriorityQueue<>();

Is there an alternative available in java collections to achieve something like this?

Uttam
  • 718
  • 6
  • 19
  • nopes @tgdavies – Uttam May 23 '22 at 06:18
  • 2
    What part of your question did that not answer? – tgdavies May 23 '22 at 06:25
  • 1
    @tgdavies While I am no thought reader, a guess would be that it’s not so much that that question seems to be about `int`, not `long` (not even explicit) but more that that question is asking about transferring numbers from an *array*, which isn’t the issue here at all. While you and I make the necessary abstractions easily, we should not expect the same from everyone here. – Ole V.V. May 23 '22 at 06:56

1 Answers1

4

Java doesn't allow primitive types in generics. You must use wrapper class like below.

PriorityQueue<Long> pQueue = new PriorityQueue<>();
Yuvaraj R
  • 107
  • 1
  • 5