- java program to remove vowels from a string
- To remove vowels from a string we can use predefined method of string replaceAll()
- By passing all vowels to the method replaceAll() with empty it will replaces all vowels with empty.
- Check below topic for more programs on string
- Java Experience interview programs on strings
Program #1: Java example program to remove all vowels from a String
- package inheritanceInterviewPrograms;
- public class RemoveVowels {
- /**
- * @www.instanceofjava.com
- * @String interview programs asked in interviews
- * @Remove vowels from a string in java
- */
- public static void main(String[] args) {
- String str = "RemoveVowels";
- String resustr = str.replaceAll("[aeiouAEIOU]", "");
- System.out.println(resustr);
- }
- }
Output:
- RmvVwls
Program #2: Java example program to remove all vowels from a String by taking input from user
No comments