When I use System.out.println(afterSort) the output is fine, but when I add some String in the System.out.print(" " + afterSort), it prints some weird chars.
First, the chars are not weird. The output basically is telling you that it is a char array, at a particular hashcode.
The reason you are getting it is because there is no special handling of char arrays for string concats. The char array is simply converted to a string with the toString() method, which by default, converts it to the type at a hashcode address.
Henry