Having trouble declaring and then initialising an array of strings in java. Was confused as to why it was happening so copied a peice of example code from Grails Cookbook and that doesnt seem to work either?
public class StringArray{
String[] testArray = new String[5];
testArray[0] = "Daddy";
testArray[1] = "Mommy";
testArray[2] = "Brother";
testArray[3] = "Sister";
testArray[4] = "Dog";
}
sample of error messages
C:\Users\aejmu\Desktop\MSc_CIS\javaLabs>javac StringArray.java
StringArray.java:5: error: ']' expected
testArray[0] = "Daddy";
^
included a screenshot of the code in sublime. Im sure there's an obvious reason for this but i cant for the life me figure it out.