Java中,字符串數組的定義方式有以下幾種:
String[] arr = {"str1", "str2", "str3"};
String[] arr = new String[3];
arr[0] = "str1";
arr[1] = "str2";
arr[2] = "str3";
List<String> list = Arrays.asList("str1", "str2", "str3");
String[] arr = list.toArray(new String[list.size()]);
String str = "str1,str2,str3";
String[] arr = str.split(",");