Java:更改预填充的字符串数组列表中的元素

nub*_*bme 2 java arrays string list set

我有一个已在storeInv中填充的字符串数组列表.如何更改字符串数组中的特定元素?例如下面的代码......

谢谢=]

List <String[]> storeInv ;  //assume already populated with elements
String[] store = storeInv.get(5);
store[1] = 123;

store.set(5, store[1]);  //this gives me an error.
Run Code Online (Sandbox Code Playgroud)

Ste*_*n C 5

List <String[]> storeInv = ...
String[] store = storeInv.get(5);

// This updates an element in one of the arrays.  (You cannot
// assign an integer literal to a String or a String array element.)
store[1] = "123";

// Compilation error!  'store' is an array, so there is no 'set' method.
store.set(5, store);

// This updates an array in the list ... but in this
// case it is redundant because the 5th list element
// is already the same object as 'store'.
storeInv.set(5, store);
Run Code Online (Sandbox Code Playgroud)