[Solved] String.compareTo() vs String.matches() in Java Performance


Not tested with data set but checking to the source codes of compareTo and matches
it seems compareTo would be faster as matches then again calls Pattern.matches and includes other function calls as well (since matches takes regex as input – regex compilation puts extra overhead.

Though since matches accepts regex as well it has his its own plus points

solved String.compareTo() vs String.matches() in Java Performance