Tuesday, May 11, 2021

Adv. Java Slip2 Solution

 

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

import java.util.*;
class vowel extends Thread
{
            String s1;
            vowel(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 Demov {
    public static void main(String[] args)
    {
            Scanner sn=new Scanner(System.in);
            System.out.println("Enter a string");
            String str1=sn.next();
            vowel v=new vowel(str1);
   }
}

/* Output*/

D:\JavaP>javac Demov.java

D:\JavaP>java Demov
Enter a string
India
Vowels are
 I i a
D:\JavaP>

No comments:

Post a Comment

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...