Write a Java Program to Remove or Delete Vowels from String using Function

By | 08.03.2017

Java Program to Delete Vowels from String

Write a Java Program to Remove or Delete Vowels from string using inbuilt function . For this program, you have to first ask to the user to enter the string and start deleting/removing all the vowels present in the string as shown in the following  program.

Since, We have two methods to delete vowels from the string : –

First method that we already discussed in the previous post that is to Program to Remove or Delete vowels manually .

Second method is shortcut method that uses the method replaceAll( ) to replace all the vowels with no-space from the string then copy that string into another string without having any vowels.

Java String replaceAll() :

The java string replaceAll() method returns a string replacing all the sequence of characters matching regex and replacement string.

Syntax :

public String replaceAll(String regex, String replacement)


  • regex — This is the regular expression to which this string is to be matched.
  • replacement — This is the string to be substituted for each match.

Return Value

This method returns the resulting string.

Following Java program removes all the vowels present in the string using inbuilt function.We use the function named replaceAll() to remove or delete all the vowels from the string.

Here the program is successfully compiled(build) and run (Netbeans) on the windows System and produce output below .Let’s look at the following program :







0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments