Thursday, October 16, 2008

Java sort() Method Example

If you want to sort string characters then this example is the best for you. The sort() method sort words in ascending order. Look a simple example of sort() method given below :

import java.util.*;
import java.lang.String;

public class sortstr{
public static void main(String args[]){
String str = "Java String Example";
char[] content = str.toCharArray();
String sorted = new String(content);

Result : EJSaaegilmnprtvx