- 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
Program #1: Java example program to remove all vowels from a String
Output:
- package inheritanceInterviewPrograms;
- public class RemoveVowels {
- /**
- * @http://corejavawithselenium.blogspot.in/
- * @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
No comments:
Post a Comment