Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Queue of Queues

875749Nov 24 2011 — edited Nov 25 2011
Hey, everybody! I'm trying to do something fairly simple but I'm running into a little trouble with it.

I'm trying to simply make a queue of queues. I can make the actual container, but when it comes time to add a new queue to the main queue, it gives me the error:

WorldGen.java:16275: java.util.Queue is abstract; cannot be instantiated
kingdoms.add(new Queue<Queue<Point>>());

^
1 error

Here's the implementation of the method I used:
private static void generateKingdoms(int width, int height)
	{
		// create a queue of queues of kingdom "points" for each palace
		Queue<Queue<Point>> kingdoms = new LinkedList<Queue<Point>>();
		
		// create an array of randomized colors to be used as the kingdoms' boundary colors
		int colorArray[] = new int[numPalaces];
		
		// search the entire image for all of the palaces
		for (int y = 0; y < height; y++)
		{
			for (int x = 0; x < width; x++)
			{
				if (getPixel(x, y) == PALACE)
				{
					kingdoms.add(new Queue<Queue<Point>>());
				}
			}
		}
	}
I understand the Queue is an abstract class and needs to be interfaced with a LinkedList type, but when I put make the queue add a LinkedList object instead of a Queue, it states that the interface is looking for a Queue. A workaround or some advice would be greatly appreciated :] Thank you!

Colton
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 23 2011
Added on Nov 24 2011
4 comments
200 views