• Post Reply Bookmark Topic Watch Topic
  • New Topic

java program to show repetition of characters in a word  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

when i run this program with an input of "aaaaaa" it never asks for the do you want to continue part, that means it never exits the for loop and shows do you want to continue again or not. But if i put john than it asks do you want to continue.
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vaibhavi nair wrote:this program is to show the repetition of characters in a word. but whenever i put "java" or "sangeeta" as the input, the screen doesn't show "do you want to continue:Y/N" statement,or i would say the statement out of the for loop is not running. I am not getting what is the problem. if i put any other name which does not have a in between. The "do you want to continue:Y/N" statement shows up. please help.

First, please UseCodeTags (←click).

Second, it's not clear from your explanation (or your code) exactly what you want the program to output.

Third, a couple of tips for you:
1. br.readLine().trim() will return an already trimmed line.
2. You might be better off using a structure like a Map to hold your counts. If I were doing it, I'd probably use a HashMap<Character, AtomicInteger>. I'll leave you to work out why.

Winston
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I recommend you go through the Java Tutorials until you read about Maps, as WG has already suggested.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!