I have a String[] that looks like this where the first String is aways a property name and the second is the value:
String[] full = { "property1", "value1", "property2", "value2", "property3", "value3" };
I want to split that String[] into two other String[]s like this:
String[] properties = { "property1", "property2", "property3" };
String[] values = { "value1", "value2", "value3" };
Is there any way of doing this programmatically?
PS: The number of property/value Strings in full may vary
The simplest approach would just be:
It’s hard to see how you’d be able to do it in a much simpler way than that. You probably want validation to start with that
full.lengthis even.Any reason for building two arrays instead of (say) a
Map<String, String>?