• Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot find symbol - method get(java.lang.Integer)  RSS feed

 
Noffica Rostt
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have such a HashMap:
Which I then populate with a total of 17 entries in this fashion:

Now, I get the error when I try to create this method:


I can't, for the life of me, figure out why. Can anyone help?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37462
537
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

This code assumes allYearsSet is a list because lists have indexing or a map with an int key.


A set does not allow duplicates and does not have order. Therefore you can't ask for a specific element by index. I think you want to be using the map you created earlier as opposed to the set on that line of code.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no get method in the java.util.Set interface
 
Noffica Rostt
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realised that as soon as I submitted this question. Thank you for the confirmation.

This was a case of beginner's PEBCAK.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!