• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array & String

 
ABDUL WARIS
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every one,
I am just a bigener in the field of java and having a problem that I am trying to solve the following:
1. Check if the first word starts with 'a'
2. Check if the first word starts with a vowel
3. Find the number of words in the String(given in question) starting with a vowel
4. After finding the number of words which starts with a vowel, retrive the found words and store them in an array and print
The first three I have successfully solved which show in the following code but the fourth one I tried my best but failed
I would request to please explain me to how to solve this
code:

(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited October 26, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like this has more to do with Java in General than with the JavaRanch site. I'm moving this to Java in General( beginning ).
 
Colin Kenworthy
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of holding all your words in a String, try putting them into an array of Strings

now you can loop through the words array printing those you are interested in.
 
Argm Mastoi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R u in Operation Badar and is your teacher Sir Baseer? well answer is:
1. when you are checking the first word, increase counter if it's starting with a vowel.
2. take a temporary string "temp" and store the word starting with a vowel in it + increase your count at this step also.
3. creat an array of strings.
4. try to save the word u caught in temp at the succeeding index of the array.
i want to give a good practice, so that u can become a good programmer. If any thing is annoying ask it again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic