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 ->
Maybe it's not the fastest answer, but it must be shortest answer.
boolean hasSameChar(String str1, String str2){ for(char c : str1.toCharArray()){ if(str2.indexOf(c) < 0 ) return false; } for(char c : str2.toCharArray()){ if(str1.indexOf(c) < 0 ) return false; } return true; }