Java tutorial
public class Main { public static void main(String[] args) { int count = 1; String userInput = "this is a test"; char ch = userInput.charAt(0); for (int i = 1; i < userInput.length(); i++) { if (userInput.charAt(i) == ch) count++; } System.out.println(count); } }