After meddling with arrays and countless google searches, I can't seem to find the answer.
public static void main(String args[]){
String[] names = new String[4]; //I want to fill this up with data from country
country(names);
System.out.println(names(0)) //I want this to display Madrid
}
public static void country(String[] names){
names[0] = "Madrid";
names[1] = "Berlin";
return;
}
I'm not sure if this explains what I'm trying to do.
()instead of[]to access the 0-th array element?System.out.println(Arrays.toString(names));