Answers for "array sort java alphabetical"

4

java sort string characters alphabetically

// java sort string characters alphabetically
import java.util.Arrays;
public class CharactersAlphabetically
{
   public static void main(String[] args)
   {
      String strInput = "flowerbrackets";
      // converting string to char array
      char[] ch = strInput.toCharArray();
      // sorting char array
      Arrays.sort(ch);
      // converting char array to string
      String strSorted = String.valueOf(ch);
      System.out.println("sort string characters alphabetically: " + strSorted);
   }
}
Posted by: Guest on February-19-2021
1

java sort list alphabetically

Assuming that those are Strings, use the convenient static method sort…

 java.util.Collections.sort(listOfCountryNames)
Posted by: Guest on October-06-2020

Code answers related to "array sort java alphabetical"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language