Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class _07_CountSubstringOccurrences {
- public static void main(String[] args) {
- Scanner sc = new Scanner (System.in);
- String text = sc.nextLine().toLowerCase();
- String target = sc.nextLine().toLowerCase();
- int countOfRepeats = 0;
- for (int i = 0; i <= text.length() - target.length(); i++) {
- if (text.substring(i, i + target.length()).equals(target))
- countOfRepeats++;
- }
- System.out.println(countOfRepeats);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement