• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java program to show repetition of characters in a word

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I just had the craziest dream. This tiny ad was in it.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic