"cannot instantiate the type queue" java

Hi all

I have a class name ChildG
I a different class Parent, I am doing

private Queue<ChildG> childList;
Queue<ChildG> childList = new Queue<ChildG>();

Then comes the error "cannot instantiate the type queue" java
The literature says that Queue is not a class but an interface..  
How can I correct this?
class constructor
public ChildG(String name, double[] exprValues){
	childName = name;
	this.exprValues = new double[exprValues.length];
	for(int i = 0; i < exprValues.length; i++)
		this.exprValues[i] = exprValues[i];

Open in new window

Who is Participating?
cmalakarConnect With a Mentor Commented:
You need to use any concrete class that implements queue.

Queue<ChildG> childList = new LinkedList<ChildG>();
for_yanConnect With a Mentor Commented:
Queue is interface - you cannot say new Queue()

You can instantiate clasess but not interfaces.

Queue can serve as the type, for example:

Queue<ChildG> childList  = new LinkedList<ChidG>();

Here LinkedList implements Queue, and hence we can use that.

To check other classes which implement Queue interface, look under "All Known Implementing Classes:" in

You may also want to look into this..

ZURINETAuthor Commented:
Sorry did not realized that LinkedList is a class of its own

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.