So I modified an API (for command management) to use String[] instead of a list of Strings.
My problem is here:strings.subList(1, strings.length)
So I need to change this to a different alternative that would do the same job.
What exactly could I do here?
You can't get one array which is a sliced view of another - but you can make a list view over an array, and then use sublist on that:
List<String> stringList = Arrays.asList(strings);
List<String> subList = stringList.subList(1, strings.length);
Now you won't be able to pass that to anything taking an array, of course...
So your options are:
List<String>
everywhere - this would be my suggestion, as collection classes are generally more flexible than arraysSystem.arraycopy
or Arrays.copyOfRange
)See more on this question at Stackoverflow