-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchstr.java
More file actions
59 lines (39 loc) · 841 Bytes
/
Matchstr.java
File metadata and controls
59 lines (39 loc) · 841 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Search 1st string are availavble in 2nd string or not
import java.util.*;
public class Matchstr
{
public static void main(String[] args)
{
int i,flag=1,len1,len2;
String s1,s2;
Scanner s=new Scanner(System.in);
System.out.println("Enter the 1st String! ");
s1=s.nextLine();
System.out.println("Enter the 2nd String! ");
s2=s.nextLine();
len1=s1.length();
len2=s2.length();
for(i=0;i<=len1;i++)
{
if(s2.contains(s1))
{
flag=1;
break;
}
else
{
flag=0;
}
}
System.out.println();
if(flag==1)
{
System.out.println(s1+" Matched in "+s2);
System.out.println(" String 1 is Available in String 2!!");
}
else{
System.out.println("String is not matched! ");
System.out.println(s1+" not Matched "+s2);
}
}
}