public static int substringsCount(String string, String pattern) {
		if(string == null || pattern == null)
			return -1;
		char[] str = string.toCharArray();
		char[] pat = pattern.toCharArray();
		
		int startIndex = 0;
		int lastIndex = 0;
		int count = 0;
		
		while(lastIndex < str.length) {
			if(lastIndex - startIndex >= pat.length || str[lastIndex] != pat[lastIndex-startIndex]) {
				startIndex++;
				lastIndex = startIndex;
			} else if(lastIndex - startIndex == pat.length-1) {
				count++;
				startIndex = lastIndex+1;
			}
			lastIndex++;
		}
		return count;
	}