Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

parsing a line

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi I have this line in a file

"AxBrCrAx"....... //like this

I want to know how can I find out how many times "A" occured with "x" and also how man times "r" occurred? any simple solution?

thanks
 
Marshal
Posts: 76483
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds simple enough, yes.

But we don't give out complete solutions here. What have you managed so far and how is it working?
 
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

Mohammad Ashari Rahman wrote:I want to know how can I find out how many times "A" occured with "x" and also how man times "r" occurred? any simple solution?


How simple is simple? But the answer is basically: yes.

However, it starts with two things: a pencil and a piece of paper.

You will never write a good Java program (at least at this stage) unless you can describe the solution on paper and in English (or your native language).

So: How would you find the number of times 'A' occurs with 'x'? (Hint: tackle that first, and treat it separately from finding the number or 'r's)

HIH

Winston
reply
    Bookmark Topic Watch Topic
  • New Topic