Java / Arrays
How do I initialize a String array?
String myFruits[]; myFruits = new String[] { "Apple", "Pineapple", "Strawberry" };
or just in one line,
String myFruits[] = new String[] { "Apple", "Pineapple", "Strawberry" };
more simpler,
String[] myFruits = { "Apple", "Pineapple", "Strawberry" };
when passing as an argument to a method,
methodName(new String[] { "Apple", "Pineapple", "Strawberry" });
More Related questions...