-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart2.java
33 lines (30 loc) · 843 Bytes
/
part2.java
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
/**
* Write a description of part2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class part2 {
public int howMany(String stringa, String stringb){
int occurence = 0;
//int startIndex = 0;
int currIndex = 0;
while(true){
currIndex = stringb.indexOf(stringa, currIndex);
if (currIndex == -1 || occurence > 10) break;
else {
occurence = occurence + 1;
//currIndex = currIndex + stringa.length();
}
}
return occurence;
}
public void testHowMany(){
String a = "GAA";
String b = "ATGAACGAATTGAATC";
String c = "AA";
String d = "ATAAAA";
System.out.println(howMany(a,b));
System.out.println(howMany(c,d));
}
}