Write a multithreading program in java to display all the vowels from a given String.(Use Thread Class)

import java.lang.*;
import java.util.*;
class Vowels extends Thread
{
            String s1;
            Vowels(String s)
            {           s1=s;
                        start();
            }
            public void run()
            {
                        System.out.println("Vowels are  ");
                        for(int i=0;i<s1.length();i++)
                        {
                                    char ch=s1.charAt(i);
                        if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
                                                System.out.print(" "+ch);
                        }
            }
}
public class Demo1 {
    public static void main(String[] args)
    {
            Scanner sn=new Scanner(System.in);
            System.out.println("Enter a string");
            String str1=sn.next();
            Vowels v=new Vowels(str1);
   }
}

Comments

Post a Comment

Popular posts from this blog

Write a java program to create Teacher table(TNo.TName, Sal, Desg) and insert a record in it.

Create a JSP page to accept a number from an user and display it in words: Example: 123 – One Two Three. The output should be in red color.