Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pleas help with array

 
Ronald Pruitt
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on an assignment that is to make a heap from an array. One thing I must do is if an item is already in the array it is not to be added again, but the value only to be incremented. I have had limited success in that I can get it to increment but the word is also added to the list. Also, when I place the first to values in the list they automatically increment, but elements after that do not. Can anyone help please.

in the test bed I have the following:

which when I ask it to print gives me;
The Heap values are: 1 = (Key-> dog, Count -> 2)
 
Ronald Pruitt
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've continued trying to work on this but to no avail, can anyone help, please
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little puzzled as to why you are doing this. Would a Map (such as a Hashtable or HashMap) not serve the purpose?
Consider:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic