My output :
a I A
S m m .
package com.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
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
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
char[] charArray = input.toCharArray();
/* for (char a : charArray) {
System.out.println(a);
} */
ArrayList<Character> arl1 = new ArrayList<Character>();
ArrayList<Character> arl2 = new ArrayList<Character>();
for (int i=0; i < charArray.length; i++) {
char p = charArray[i];
if (isVowel(p) == true) {
arl1.add(p);
} else {
arl2.add(p);
}
}
for (char y : arl1) {
System.out.print(y + " ");
}
System.out.println("");
for (char z : arl2) {
System.out.print(z + " ");
}
}
// 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;
}
}