I like my solution, but not passing 4th requirement, anyone can tell me why do?
Looked up their solution and it seems much more complicated.
package com.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
/*
Vowels and consonants
*/
public class Solution {
public static char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
public static void main(String[] args) throws Exception {
// write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
char[] array = s.toCharArray();
ArrayList<Character> vowelList = new ArrayList<>();
ArrayList<Character> consonantsList = new ArrayList<>();
for(char c : array){
if(isVowel(c))
vowelList.add(c);
else
consonantsList.add(c);
}
for(Character c : vowelList)
System.out.print(c + " ");
System.out.println();
for(Character c : consonantsList)
System.out.print( c + " ");
}
// The method checks whether a letter is a vowel
public static boolean isVowel(char c) {
c = Character.toLowerCase(c); // Convert to lowercase
for (char d : vowels) // Look for vowels in the array
{
if (c == d)
return true;
}
return false;
}
}