write a method in java that takes an array of Strings as an argument. Each element of the argument array will contain a single word.The method must return an array of strings that contains only the words from the argument array that start with a vowel A, E, I, O, or, U).
This is what I have so far:
import java.util.Scanner;
import java.util.Arrays;
public class VowelMethod {
public static String[] beginsWithVowel (String [] args ) {
String vowel [] = new String[10];
{
}
int count=0;
for(int i=0; i< count; i++) {
if ( vowel.startsWith ("a") || vowel.startsWith ("e") || vowel.startsWith ("i") || vowel.startsWith ("o") || s.startsWith ("u") );
return vowel;
//My error with this is that the startsWith method is only defined for String type, and not the String[] type.
vowel[0]
,vowel[1]
and so on. In a loop. (Use a variable instead of0
and1
). And setcount = vowel.length
so you loop over the entire array. – keyser Nov 18 '13 at 21:45<= args.length
. – SimplyPanda Nov 18 '13 at 21:49Each element of the argument array will contain a single word.The method must return an array of strings
so his function signature is OK. – fvu Nov 18 '13 at 21:51