Java Program to remove vowels from an input string
Remove Vowels from a String
In this article we will learn how to code a Java program to remove vowels from a string. ‘A’, ‘E’, ‘I’, ‘O’, ‘U’ are five vowels out of 26 characters in English alphabet letters. Java programming is case sensitive, and hence lowercase and uppercase characters are considered differently, so we will have to check for both the cases and then we can remove the vowels from a string
- Step 1: Take input str as a String.
- Step 2: Convert the string into character array.
- Step 3: Traverse the complete array and check if the character present at particular index is vowel or not.
- Step 4: If the character if vowel the continue the loop else concatenate the character into resultant string.
- Step 5: Print the resultant string.
Code in Java
public static void main(String args)
Scanner sc=new Scanner(System.in);
if(arr[i]=='a' || arr[i]=='e' || arr[i]=='i' || arr[i]=='o' || arr[i]=='u' || arr[i]=='A' || arr[i]=='E' || arr[i]=='I' || arr[i]=='O' || arr[i]=='U')