The code defines a method to count the number of occurrences of a character in a string. It then prompts the user to enter a string, loops through each character, counts the occurrences of that character, and prints the results.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
21 views
Test String
The code defines a method to count the number of occurrences of a character in a string. It then prompts the user to enter a string, loops through each character, counts the occurrences of that character, and prints the results.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
import java.util.
Scanner;
public class TestString {
public static int Find(String string, char key) { int count = 0; for (int i = 0; i < string.length(); i++) { if (string.charAt(i) == key) { count++; } } return count; }