1. package com.instanceofjava; 
  2.  
  3. public class SortString {
  4.  
  5. public static void main(String[] args) { 
  6.  
  7.   String original = "edcba";
  8.  
  9.   char[] chars = original.toCharArray();
  10.  
  11.   Arrays.sort(chars);
  12.  
  13.   String sorted = new String(chars);
  14.   System.out.println(sorted);

  15. }





OutPut:
  1. abcde



Instance Of Java

We are here to help you learn! Feel free to leave your comments and suggestions in the comment section. If you have any doubts, use the search box on the right to find answers. Thank you! 😊
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu