2010-06-08 7 views
2

storeInv에 이미 채워진 문자열 배열 목록이 있습니다. 문자열 배열의 특정 요소를 어떻게 변경합니까? 예를 들어 아래의 코드 ...Java : 미리 채워진 요소를 문자열 배열로 변경

감사합니다 =]

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. 
+0

그리고'점 [1] = 123;'당신에게 오류를 제공하지 않습니다? – Artefacto

+1

@ battousai622 : * store [5] = store [1] * 같은 것을 의미합니까? – SyntaxT3rr0r

+0

나는'storeInv.set (5, store);를 의미 할 것이라고 확신한다.하지만 이미 필요하기 때문에 필요 없다. –

답변

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); 
+0

ic, thanks =]]] – nubme

+0

설정 방법이 저를 위해 작동하지 않습니다. 나는 이클립스의 자동 완성에 나타날 수 없으며 String []에서 사용하려고 시도한다. 응? –

관련 문제