Is there a way to check if two strings contain the same characters. For example,
abc, bca -> true
aaa, aaa -> true
aab, bba -> false
abc, def ->
As a (nitpicking ;-) ) side note:
Be aware that the solutions proposed here only work for strings composed of characters from the Basic Multilingual Plane (BMP) of Unicode.
Characters outside the BMP are represented as a pair of char
in a String
, so you need to pay extra attention, so you keep the pairs together. See the Javadocs of java.lang.Character
for the gory details.
Fortunately, most characters outside the BMP are rather exotic. Even most of Japanese and Chinese is in the BMP...