Sort string

PHOTO EMBED

Tue Feb 15 2022 16:31:24 GMT+0000 (Coordinated Universal Time)

Saved by @Harsh #java ##string ##interviewquestions

 static void sortString(String str) {
        char []arr = str.toCharArray();
        Arrays.sort(arr);
        System.out.print(String.valueOf(arr));
 }
content_copyCOPY

first we convert the given string into array, via toCharArray() method which converts the string into sequence of characters. then we sort the array Atlast we convert the array into string via valueOf() method and print it.

https://www.interviewbit.com/blog/sort-string/