Java中,可以使用以下方式定義字符串數組:
String[] myArray = {"Hello", "World", "Java"};
String[] myArray = new String[3];
myArray[0] = "Hello";
myArray[1] = "World";
myArray[2] = "Java";
String[] myArray = new String[]{"Hello", "World", "Java"};
無論使用哪種方式定義字符串數組,都需要注意數組的索引從0開始。