wood burning stoves*
The moose likes Java in General and the fly likes Queue interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Queue interface" Watch "Queue interface" New topic
Author

Queue interface

Joanna Spence
Greenhorn

Joined: May 31, 2010
Posts: 23
In a java example it shows you can implement a Queue with:

Queue queue= new Queue();

However, I receive an error stating it's abtract and cannot be instantiated...how do I work with this abstract class?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

Find a non-abstract class that implements the Queue interface, then use it on the right hand side.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Hi Joanna,

Maybe the example is old(ish) was referring to a Queue class written before the Java API contained such an interface? Another giveaway that this might be old is that the modern Queue interface takes a type parameter, which isn't in your example.

To work with a Queue nowadays, anyway, you'd need to create an instance of some class that implements Queue, like LinkedList. So



[Jess in Action][AskingGoodQuestions]
Joanna Spence
Greenhorn

Joined: May 31, 2010
Posts: 23
Ooooooh...okay I will try that...
Joanna Spence
Greenhorn

Joined: May 31, 2010
Posts: 23
Ok...it compiled, but it states to compile with -Xlint because it's marked for unchecked or unsafe operations..
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1666
    
    7

That's down to Generics, or rather lack thereof. Have a look at this tutorial if you would like to know more about that subject. For now though, realize that it's a warning, not an error, and you could ignore it if you so choose. The -Xlint suggestion you can safely ignore for now. This javac option will enable all compiler warnings. If you want to know more about javac and its options, have a look here.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Queue interface
 
Similar Threads
JMS and MQ Websphere Very urgent
mdb doesn't catch messages in point2point
Cant get reference to Queue
Webshpere security exception
JMS - MDB - WebSphere