1
Queue<Integer>[] queues = new Queue[3];
for(int i=0;i<3;i++) {
    queues[i] = new LinkedList<Integer>();
}
Queue thisqueue = queues[1];
while(thisqueue.peek()<10) {}

This is my java code. when I run this code the eclipse tell me The operator < is undefined for the argument type(s) Object, int

I can't understand I store everything in queue as Integer why it become object when I use peek().

How to fix this? I want to peek the tail number as int and compare with 10.

Weiheng Li
  • 39
  • 1
  • 1
  • 8

1 Answers1

1

You haven't told the compiler what type of objects thisqueue holds. Try replacing:

Queue thisqueue = queues[1];

with

Queue<Integer>  thisqueue = queues[1];
Jared Stewart
  • 571
  • 3
  • 10