Saturday, 20 February 2016

Sorting string array using SetTree

Code is straight forward
import java.util.TreeSet;
import java.util.Set;
import java.util.Collections;
public class Sort{

public static void main(String [] args){
String [] input = new String[] {"this", "is", "a", "test", "string"};
Set<String> stringSet = new TreeSet<>();
Collections.addAll(stringSet, input);
System.out.println(stringSet);
}
}

 

No comments:

Post a Comment