I wanted to know how can I compare two rearranged strings E.g if String a="string" ,String b="tsrngi" ... If I compare a.equals(b), It will return false because of order of characters... I want it to return true because characters are same but only order is different.. Thanks
Sort them, then compare. To sort, use something like:
char[] content = unsorted.toCharArray();
java.util.Arrays.sort(content);
String sorted = new String(content);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With