private int countChar ( String string , char c ) { int count = 0 ; final int max = string . length ( ) ; for ( int i = 0 ; i < max ; i ++ ) { if ( c == string . charAt ( i ) ) { count ++ ; } } return count ; }
Counts the number of times the character is present in the string .