• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Program to find repeated words

 
Tarun Oohri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody
I have made a program which finds the number of occurrence of the words. It is as follows :Output is coming {This=0, is=1, me=1, tarun=1, ohri=1}
Why is it coming wrong ? Any Guess ??
 
Tarun Oohri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved...sorry ....My bad
 
Winston Gutkowski
Bartender
Pie
Posts: 10508
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tarun Oohri wrote:Why is it coming wrong ? Any Guess ??

Yes. Integer is an immutable class (ie, you can't change it), so you have to replace it in your Map every time you get a repeated word.

You might find things easier if you use AtomicInteger instead, because you can update those.

HIH

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic