It probably doesn't matter if you don't make this comparison many thousands of times. However, if you look at what each of these statements does:
boolean areEqual = Integer.parseInt(b) == a; This statement parses the String value once, then makes a very quick comparison of two primitive int values.
boolean areEqual = String.valueOf(a).equals(b); This statement processes a String once to create a String a , and then compares String . Faster steps, more internal logic, therefore less effective.
Stormehawke
source share