NiCE interview question

Given a String s1= Apple, Write a program to convert s1 to array, and put vowels into array

Interview Answer

Anonymous

16 Oct 2024

String s1= Apple char[] characters = s1.toCharArray(); char[]newvowels = ""; for (int i=0; i <=characters.length-1; i++) { if (characters[i]== 'a' || characters[i] == 'e' || characters[i] == 'i' || characters[i] == 'o' || characters[i] == 'u') newvowels = newvowels + characters[i]; }