"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

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

Queue<ChildG> childList = new LinkedList<ChildG>();
0
 
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>();

0
 
cmalakarCommented:
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

http://download.oracle.com/javase/1,5.0/docs/api/java/util/Queue.html
0
 
cmalakarCommented:
You may also want to look into this..

http://mindprod.com/jgloss/interface.html#INSTANTIATING
0
 
ZURINETAuthor Commented:
Sorry did not realized that LinkedList is a class of its own

Regards
0
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.