Let’s say I have a String[] that looks like this:
private String[] motherOfStrings = {
"stringA",
"stringB",
"stringC",
"stringD",
"stringE",
}
Can I split it into multiple String[] like these?
private String[] childOfString1 = {
"stringA",
"stringB",
"stringC",
}
private String[] childOfString2 = {
"stringD",
"stringE",
}
Thanks guys 🙂
p.s., i did some search but most of the guides (if not all) are about splitting String[] into Strings, not another String[]. Is this even possible?
You can use
split()method for every string in your array.…if you want to split your strings by
"C"…EDIT:
Now, when you edited question I see what you want. You have to create two arrays and copy into them strings from
motherOfStrings. You can use System.arraycopy method.