I am implementing my own priority queue and using a class called sportsball that uses it. The priority queue is based on generics and uses a Node (T object, int value) (aka Name of player and their score). I am getting a class cast exception error when I try to run the program.
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LPriorityQueue$Node;
at PriorityQueue.<init>(PriorityQueue.java:35)
at sportsball.main(sportsball.java:48)
The lines in question are: PriorityQueue.java:35:
Node[] array = (Node[])(new Object[initialSize]);
sportsball.java:48:
PriorityQueue<String> queue = new PriorityQueue<String>(start, step);
Thank you for your help!
Note:
When I tried having line PriorityQueue.java:35:
Node[] array = new Node[initialSize];
the error: generic array creation pops up instead.