Private 배열에 public 데이타할당
또는
Public 메소드부터 반환된 private배열
예제
private List<testDto> testList;
public List<testDto> getTestList(){
return testList;
}
}
>>> 변경
public class ListDTO{
private List<testDto> testList;
public List<testDto> getTestList(){
List<testDto> aa = null;
if (this.testList != null ){
aa = this.testList.stream().collect(Collectors.toList());
}
return aa;
}
}
단순 배열인 경우 clone 만 사용하여 변환하면됨
private String[] arrCol = {};
public void setTestName(String[] col} thows IllegalArgumentException{
String[] cloneArr = {};
if (col != null ){
cloneArr = col.clone();
}
this.arrCol = cloneArr;
}
댓글 없음:
댓글 쓰기