Java Code to Delete Vowels from String using Function - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Monday, September 25, 2017

Java Code to Delete Vowels from String using Function

Write a Java Code to Delete Vowels from String using Function

Program:
/* Java Program Example - Remove/Delete all Vowels from String */

import java.util.Scanner;

public class JavaProgram
{
public static void main(String args[])
{
String strOrig, strNew;
Scanner scan = new Scanner(System.in);

System.out.print("Enter a String : ");
strOrig = scan.nextLine();

System.out.print("Removing Vowels from The String [" +strOrig+ "]\n");
strNew = strOrig.replaceAll("[aeiouAEIOU]", "");

System.out.print("All Vowels Removed Successfully..!!\nNow the String is :\n");

System.out.print(strNew);
}
}


Output:
Enter a String : Hello World
Removing Vowels from The String [Hello World]
All Vowels Removed Successfully..!!
Now the String is :
Hll Wrld

No comments:

Post a Comment