Q:

Why my code is not converting the SortedSet to an Array

I am inputting a string from the user and then sorting the list in first step and then removing the duplicates in the second step.But the code is giving error.Please help!!!
Here is the code
import java.util.*;

class stringSort
{
    public static void main(String args[])
    {
        String s1;
        char[]s2;
        System.out.println("Enter the string");
        Scanner s=new Scanner(System.in);
        s1=s.next();
        //call the sort method to sort the string
        s2=sort(s1);
        System.out.println(String.valueOf(s2));
        //remove duplicate entries in the sorted string
        SortedSet<Character> set=new TreeSet<Character>();
        set.addAll(Arrays.asList(s2));
        System.out.println(String.valueOf(set.toArray()));
    }
    static char[] sort(String s)
    {
        char []temp=s.toCharArray();
        Arrays.sort(temp);
        return temp;
    }
}

It gives the error
no suitable method found for addAll(List<char[]>)
        set.addAll(Arrays.asList(s2));

A:

But the code is giving error

SortedSet<char> set=new TreeSet<char>();

This is illegal and won't compile. If you want to use a character set you have to use the Character class.
SortedSet<Character> set=new TreeSet<Character>();

UPDATE

It gives the error no suitable method found for addAll(List) set.addAll(Arrays.asList(s2));

That's because you need a Character array, not a char array, so you have two options:

Change char[]s2; to Character[]s2; 
Convert the char array to a Character array before calling the sort method:
Character[] a = new Character[s2.length];
System.arraycopy(s2, 0, a, 0, s2.length);
a = sort(s1);

In both cases you'll have to change your sort method to this:
static Character[] sort(String s) {
    Character[] temp = new Character[s.length()];
    for (int i = 0; i < temp.length; i++) {
        temp[i] = s.charAt(i);
    }
    Arrays.sort(temp);
    return temp;
}

