Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Get the random characters and print only the vowels in java.
is it possible to get only vowels from the randomly generated characters in java? Help me with that please.
1 Resposta
0
A randomly generated String, you mean ?
If yes:
String getVowels(str)
{
char[] vowels = {'a', 'e', 'i', 'o', 'u', 'y'};
String output = "";
for(int i = 0; i < str.length; i++)
{
for(int j = 0; j < vowels.length; j++)
{
if(str.charAt(i) == vowels[j])
{
output += str.charAt(i);
break;
}
}
}
return output;
}