Is there a way in Java to assign multiple values to an Array in one statment then later you can still be able to append to the same array other values?
e.g. Having a String array defined already with length of 4
String[] kids = new String[4];
I would like to assign multiple values (2 values for example) to the array in one statment; maybe something close to the array init
kids = {"X", "Y"};
or the array redefinition
kids = new String[] {"X", "Y"};
but without loosing the initial array as later I will need to add to it other values e.g.
if(newKid) {
kids[3] = "Z";
}
or there is no way to achieve this and have to assign values one by one
kids[0] = "X";
kids[1] = "Y";
if(newKid) {
kids[3] = "Z";
}