String
immutable in Java. That way, when the String
array in your question is duplicated, they do not require as much space as you expect. In fact, overhead can be minimal.
In other words, Java Arrays#sort()
might just be great for your solution. You can check the performance yourself.
For your Ankit answer and dlev question title, the answer is just perfect.
Dante is not a Geek
source share