-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquiz.java
More file actions
43 lines (25 loc) · 697 Bytes
/
quiz.java
File metadata and controls
43 lines (25 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package StringPack;
import java.util.Scanner;
public class quiz {
public static void main(String[] args)
{
Scanner scan= new Scanner(System.in);
String word1 = scan.nextLine();
String word2 = scan.nextLine();
String common="";
for(int i=0; i<word1.length()-1;i++)
{
for(int j=0;j<word2.length()-1;j++)
{
if(word1.charAt(i)==word2.charAt(j))
{
if(word2.charAt(j)!=common.charAt(common.indexOf(word2.charAt(j))))
{
common+=word2.charAt(j);
System.out.println(common);
}
}
}
}
}
}