• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Write a java program for to count each repeated letters in the given String?

 
Greenhorn
Posts: 13
Hibernate Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


for example if the given string is: The world is running java technology?

Ans:
T is =2
h is=2
e is=2
w is=1
n= 4

like wise i need out put of the program?

please help to this program with clearly ?
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you post your question with a bit more clarity? Read this page https://coderanch.com/how-to/java/HowToAskQuestionsOnJavaRanch first!
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are NotACodeMill. If you are stuck then please explain your problem and we will help you but we won't write the code for you.
 
Ranch Hand
Posts: 235
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been pondering this assignment for several hours now. It won't leave me alone. The problem is I have no clue on how to approach this.

There are the obvious, newb ways of doing this. Create a 26 element 2D array, then just read back the values, skipping the empty/null elements. There is the brute force method of a switch statement wiht 36 cases and 36 counters. Hmm, maybe something like int myCounter[36] and just increment the elements.

I'm sure there is a better way to approach this, but I'm not familiar enough with the language yet. I don't really understand the various collections -- hashmap, list array, etc.

Any hints on a possible approach that is a bit more elegant than my idiot example?

Regards,
Robert
[This is not a class assignment. I' am merely intrigued by the problem.]
 
Marshal
Posts: 76419
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to the Java Tutorials and read about all the different types of collection.
 
Campbell Ritchie
Marshal
Posts: 76419
365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use an array, you might use the letters as the indices. Remember a char is not a letter but a number, so you can do arithmetic on it.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robert D. Smith wrote:

Hmm, maybe something like int myCounter[36] and just increment the elements.



i like it!. The question is why don't you like it? What do you think can be improved? What is the drawback of this solution?
 
krishnamurthy durgam
Greenhorn
Posts: 13
Hibernate Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends finally i got the answer from Coderanch it self thanks to helping me


this is my answer wt i am lokking
 
You can't have everything. Where would you put it?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic