I want to write a simple class to process Strings (may be very long strings up to 1mil characters in it). String will basically consists of two characters \"a\" and \"b\" that
I believe this is what you want:
private static boolean check(String input) { int count = 0; for (int i = 0; i < input.length(); ++i) { if (input.charAt(i) == 'a') { count++; } } return count == input.length() >> 1; // count == input.length()/2 }