• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

uncheked or unsafe operations

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey
while comiling the following code from Head First servlets & JSP page no.82

i am getting following error

BeerExpert.java uses unsafe or unchecked operations
Recompile with -Xlint:unchked for details

please help:
akash.deo@iiitb.net
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

That's not an error, but a warning. If you recompile with javac -Xlint:unchecked BeerExpert.java it will tell you what it thinks the problem is.
What it means is that there is a risk of your putting something into the Lists and trying to get it out as a different type, in which case there will be a ClassCastException thrown.
That sort of warning only started appearing when Java5 was introduced in Autumn 2004. It can be obviated by using generics, but that is probably too advanced a topic for the earlier pages of a Head First book. By the way: was that book printed before Autumn 2004?
 
reply
    Bookmark Topic Watch Topic
  • New Topic