I am trying to make a program and am having trouble with the syntax. I'm trying to create an array as a parameter for an object, but I am having trouble with the syntax.
public class Example {
String[] words;
public Example(words) {
this.words = words;
}
}
public class Construction {
Example arrayExample = new Example({"one", "two", "three"});
}
This gives me an error when I try and compile it. Is there a way to do this without first initializing the array outside the object declaration?