12 Answers. The best way is to use str.equalsIgnoreCase ("foo"). It's optimized specifically for this purpose. You can also convert both strings to upper- or lowercase before comparing them with equals. This is a trick that's useful to remember for other languages which might not have an equivalent of equalsIgnoreCase.
. 50 340 18 291 92 435 67 0