This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Queue interface  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Sheriff
Posts: 21719
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Find a non-abstract class that implements the Queue interface, then use it on the right hand side.
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Joanna Spence
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooooooh...okay I will try that...
 
Joanna Spence
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok...it compiled, but it states to compile with -Xlint because it's marked for unchecked or unsafe operations..
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I can't beleive you just said that. Now I need to calm down with this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!