Two Laptop Bag
The moose likes Beginning Java and the fly likes Array & String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array & String" Watch "Array & String" New topic

Array & String


Joined: Oct 26, 2001
Posts: 2
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

(edited by Cindy to format code)

[This message has been edited by Cindy Glass (edited October 26, 2001).]
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
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 ).

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Colin Kenworthy
Ranch Hand

Joined: Aug 06, 2001
Posts: 88
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

Joined: Oct 16, 2001
Posts: 35
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.
I agree. Here's the link:
subject: Array & String
It's not a secret anymore!