• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiler warnings when using a SortedSet to process a HashMap's keys in order  RSS feed

 
Noffica Rostt
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My objective here is to process a HashMap's key's in order. I found SortedSet as a way to do it.

The HashMap is like this:


This is the method I am trying to write


However, the compiler gives me a warning of
NobelPrizeWinners.java uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details.


As I said, my objective here is to process them in order. If this compiler warning cannot be resolved, I am open to other methods of accomplishing my objective.

Can anyone assist?
 
Tony Docherty
Bartender
Posts: 3271
82
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a warning about not using generics, your sorted set should be declared with generics ie

BTW you don't need to add all the values individually, you could declare sortedSet as type Set<String> and use the addAll() method to add all the values in one go.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!