import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;
public class ArrayToTreeSet {
public static void main(String[] args) {
String [] arr={"java","php","html","json","ajax"};
for (String str : arr) {
System.out.println("Array element is ="+str);
}
Set<String> ts = new TreeSet<String>(Arrays.asList(arr));
// print treeset
for (String str : ts) {
System.out.println("TreeSet Element = "+str);
}
}
}
Output:
Array element is =java
Array element is =php
Array element is =html
Array element is =json
Array element is =ajax
TreeSet Element = ajax
TreeSet Element = html
TreeSet Element = java
TreeSet Element = json
TreeSet Element = php
import java.util.Set;
import java.util.TreeSet;
public class ArrayToTreeSet {
public static void main(String[] args) {
String [] arr={"java","php","html","json","ajax"};
for (String str : arr) {
System.out.println("Array element is ="+str);
}
Set<String> ts = new TreeSet<String>(Arrays.asList(arr));
// print treeset
for (String str : ts) {
System.out.println("TreeSet Element = "+str);
}
}
}
Output:
Array element is =java
Array element is =php
Array element is =html
Array element is =json
Array element is =ajax
TreeSet Element = ajax
TreeSet Element = html
TreeSet Element = java
TreeSet Element = json
TreeSet Element = php
Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.
ReplyDeletephp jobs in hyderabad.