Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class findArrayChar {
- public static int countChar(char[] source,char target){
- int counter = 0;
- for (char c : source) {
- if(c==target)
- counter++;
- }
- return counter;
- }
- public static void main(String[] args) {
- char[] matKul
- = {'p', 'e', 'm', 'r', 'o', 'g', 'r', 'a', 'm', 'a', 'n', 'b', 'e', 'r', 'b', 'a', 's', 'i', 's', 'o', 'b', 'y', 'e', 'k'};
- System.out.println("Jumlah huruf a : "+countChar(matKul, 'a'));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment