Original Question:
write the following method that returns a new ArrayList. The new list ONLY contains the vowel elements from the original list which contains an array of English characters (a,e,i,o,u).
This is what i have so far. I believe i created the right generic method to print out my Array List of characters I'm just struggling on how to put the vowels into another array and print it. Any suggestions? I think i may need to create a generic ArrayList of "vowels" to make it run? I'm i on the right track?
Thanks for any help!
Here's my code so far:
import java.util.*;
public class test5 {
public static void main(String[] args) {
Character [] letters ={'a', 'r', 'y', 'i', 'i', 'o', 's', 'p', 'q', 'x', 'd', 'e', 'j'};
Character [] vowels ={};
test5.print(letters);
test5.print(vowels);
}
public static <E> void print(E[] list) {
for (int i=0; i < list.length; i++)
System.out.print(list[i] + "");
System.out.println();
}
public <E> void vowels(E[] list){
for (int i=0; i < list.length; i++)
if (i=='a')
vowels.add(i);
else if (i=='e')
vowels.add(i);
}
public static <E> void vowelsArray(E[] list){
for(int i = 0; i<vowels.size(); i++)
System.out.print(vowels.get(i));
}
}