• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Set using generics

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,



Q. Why does the code above compiles with the following warning??

Note: TestMaps.java uses unchecked or unsafe operatio
Note: Recompile with -Xlint:unchecked for details.



--------------
Ravinder
 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ravinder-

I would guess that the warning you are getting relates to the fact that the collections and interator that you are using aren't type safe. Try making your TreeSets and your Iterator type safe and I think you'll see the warning disappear.



Hope that helps.
Joshua Smith
 
Ravinder Singh
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Joshua..
The warnings disappear if I change the statement for TreeSet instantiation to: TreeSet<String> map = new TreeSet<String>();

-----------
Ravinder
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the next time...compiler told you.

"Recompile with -Xlint:unchecked for details."

Sometimes it is useful to do, what compiler tells you.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic