0 votes
in JAVA by
How to sort a string in java?

1 Answer

0 votes
by

How to sort a string in java?

import java.util.Arrays;

public class Test

{

    public static void main(String[] args)

    {

        String original = ""edcba"";

        char[] chars = original.toCharArray();

        Arrays.sort(chars);

        String sorted = new String(chars);

        System.out.println(sorted);

    }

}

🔗Reference : stackoverflow.com

🔗Source: Java Interview Questions and Answers

🔗Reference: Javatpoint.com

Related questions

0 votes
asked Oct 19, 2020 in JAVA by rahuljain1
0 votes
asked Oct 21, 2020 in JAVA by rahuljain1
...