Not able to figure what is the issue.It is working fine for the testcase given in question
package com.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
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 {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
String[] string=s.split(" ");
char[] nonvowel=new char[10];
char[] vowel=new char[10];
int k=0;
int p=0;
for (int i = 0; i <string.length ; i++) {
char[] ch=string[i].toCharArray();
for (int j = 0; j <ch.length ; j++) {
if(isVowel(ch[j])){
vowel[k++]=ch[j];
vowel[k++]=' ';
}
else {
nonvowel[p++]=ch[j];
nonvowel[p++]=' ';
}
}
}
for (int i = 0; i <k ; i++) {
System.out.print(vowel[i]);
}
System.out.println();
for (int i = 0; i <p ; i++) {
System.out.print(nonvowel[i]);
}
}
// 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;
}
}