I know how to make an empty array, but how do I make a String
array with values from the start?
You can also initialize the String Array as follows:String[] strArray = new String[3]; strArray[0] = “one”; strArray[1] = “two”; strArray[2] = “three”; Here the String Array is declared first. Then in the next line, the individual elements are assigned values.
You could do something like this
String[] myStrings = { "One", "Two", "Three" };
or in expression
functionCall(new String[] { "One", "Two", "Three" });
or
String myStrings[]; myStrings = new String[] { "One", "Two", "Three" };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With