Arrays are of fixed length, so all you can do is replace their existing elements or create a new separate array.
This is easier if you use a List , which can be of variable length, and use addAll to add split results to this:
List<String> parts = new ArrayList<>(); parts.addAll(Arrays.asList(s1.split(" "))); parts.addAll(Arrays.asList(s2.split(" "))); parts.addAll(Arrays.asList(s3.split(" ")));
Note that you should use Arrays.asList , because split returns String[] , while addAll requires a String collection, for example. List<String> .
source share