• 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

regarding files

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to count number of vowels and consonents from a file........

my logic is: 1)creating the arraylist
2)open the file
3)and spliting the contents based on spaces
4)storing these strings in arraylist


now i'm really confused how to traverse the arraylist and how to check for vowels and cons.... please give me suggestion from here....


Thanks a LOT..............................
 
Ranch Hand
Posts: 63
Spring Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you use arraylist?
 
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

Thirumalesh yeligar wrote:how to count number of vowels and consonents from a file........


Well, the first thing is to decide what a 'vowel' and a 'consonant' are - and there's no hard and fast rule for things like 'y' (and in some cases 'h').

However, like Niraj, I wonder about the wisdom of an ArrayList - but it's purely an 'efficiency' concern; you can certainly do it that way, and there's absolutely nothing wrong with the idea.

Winston
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) stop
2) don't think about how you'd do this in java. think about how you'd do this with pencil, paper, and your own brain.
3) write down in English (or your natural language of choice) how you would do it.
4) Revise those steps until you could give them to a child, and they could follow them
5) Give that list to a child to find out where you went wrong explaining the steps, and revise. Repeat this as many times as necessary.

ONLY when you have done all the above should you consider writing a single line of code. If you are already thinking about array lists and strings, you haven't though through the problem yet. You are jumping the gun.
 
Thirumalesh yeligar
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
without using arraylist how can i do it?
 
Winston Gutkowski
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

Thirumalesh yeligar wrote:without using arraylist how can i do it?


Practically any Java collection or Map - or indeed an array (which may be fastest of all). But I just told you that you CAN do it with an ArrayList, so why are you looking around for other alternatives?

First, follow Fred's advice and get it working. Then, if you need to (and you still have time), worry about making it fast.

Winston
 
Greenhorn
Posts: 8
Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try the following code with each line of data you get from the file.

[Moderator action: solution removed]

 
Winston Gutkowski
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

Jamie Coleshill wrote:You could try the following code...


Jamie. Please DontBeACodeMill (←click).

I'm sure your motives were great, but we like to help people here, rather than just handing out solutions - especially in the 'Beginning Java' section.

By all means post something that helps Thirumalesh find his own solution, but try to avoid spoon-feeding.

Thanks.

Winston
 
reply
    Bookmark Topic Watch Topic
  • New Topic