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
public class Typo { public static void main(String[] args){ String ver = "NOK"; String text = "ababababbaba"; if( (text.length() - text.replaceAll("a","").length() ) == ( text.length() - text.replaceAll("b","").length() ) ) { ver = "OK"; } System.out.println(ver); } }