Java字符串數組可以通過以下幾種方式賦值:
String[] arr = {"Hello", "World"};
String[] arr = new String[2];
arr[0] = "Hello";
arr[1] = "World";
String[] arr = new String[]{"Hello", "World"};
String[] arr = new String[2];
for (int i = 0; i < arr.length; i++) {
arr[i] = "Element " + (i+1);
}
這些方法都可以將字符串賦值給數組。使用哪種方式取決于具體的需求和代碼風格。