Created
August 24, 2022 01:07
-
-
Save nhomble/ed850b0c3c0da05abaaebad4b4fcf90d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleLoopString { | |
public static int frequencyOf(String input, char c) { | |
if (input == null) { | |
return 0; | |
} | |
int ret = 0; | |
for (int i = 0; i < input.length(); i++) { | |
if (input.charAt(i) == c) { | |
ret += 1; | |
} | |
} | |
return ret; | |
} | |
public static void main(String[] args) { | |
System.out.println(frequencyOf("abcd", 'd')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment