Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Creative commons Attribution-NonCommercial license. NO WARRANTY IS GIVEN OR IMPLIED, USE AT YOUR OWN RISK.
public abstract class Encoding {
	public abstract String encode(String message);

Count how frequently a particular substring appears within a string.

content Text in which to scan.
substring Substring to scan for.
Number of times a substring appears in the content
	protected int countSubstring(String contentString substring) {
		int index = -1;
		int total = 0;
		while(true) {
			if(index == -1) {
				index = content.indexOf(substring);
else {
				index = content.indexOf(substringindex);
			if(index == -1) {
			index += substring.length();
		return total;
New to GrepCode? Check out our FAQ X