I got a list
List<String> paths = {"r", "e","t","t"};
and I want to add the data of paths into a CharSequence
. I have done this code:
CharSequence[] cs = paths.toArray(new CharSequence[paths.size()]);
but I don't know how to add the data in, please help, thanks
The problem is in constructing the list: you can't use array syntax like that. You'll have to add elements one by one --
List<String> paths = new ArrayList<String>();
paths.add("r");
paths.add("e");
...
and then you'll be set.
If you can use third-party libraries like Guava, you could do
ImmutableList<String> paths = ImmutableList.of("r", "e", "t", "t");