Computer Science, asked by jamesmarc7433, 8 months ago

Input two words and find out the set that will be formed by the intersection of the characters found in both the string. Eg Input 1 : DISARI Input 2 : HALDIA Output will come as : D, I , A

Answers

Answered by ripandeepkaur28
4

Answer:

import java.util.*;

class brainly

{

  public static void main()

{

 Scanner sc = new Scanner(System.in);

               System.out.println("Enter the two words : ");

 String str1 = sc.nextLine();

 String str2 = sc.nextLine();

 String common = "";  

for(int i=0;i<str1.length();i++){  

   for(int j=0;j<str2.length();j++){  

       if(str1.charAt(i)==str2.charAt(j)){  

           common += str1.charAt(i)+"";  

           break;

       }  

   }  

}  

System.out.println("common is: "+common);  

}

}

Explanation:

copy it

Similar questions