» » Sort the string using String Methods?

  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 will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Select Menu