// [ReferenceParameter.java]
public class ReferenceParameter {
public void increase(int[] n) {
for (int i = 0; i < n.length; i++) {
n[i]++;
System.out.println("n[" + i + "] : " + n[i]);
}
}
public static void main(String[] args) {
int[] ref1 = { 100, 800, 1000 }; // ref.length=3
ReferenceParameter rp = new ReferenceParameter();
rp.increase(ref1);
for (int i = 0; i < ref1.length; i++) {
System.out.println("ref1[" + i + "] : " + ref1[i]);
}
}
}
/*
* 매개변수 ref1는 stack영역에 저장된 heap영역 접근 주소이며, 실제 데이터는 heap영역에서 변경되므로 결과는 아래와 같다.
*
* 자바 실행
n[0] : 101
n[1] : 801
n[2] : 1001
ref1[0] : 101
ref1[1] : 801
ref1[2] : 1001
*/
'IT-Consultant' 카테고리의 다른 글
How to improve elasticsearch performance (0) | 2011.06.30 |
---|---|
elasticsearch.yml (0) | 2011.06.30 |
public, private, protected의 속 시원한 설명 (0) | 2011.06.25 |
ElasticSearch need 1g memory by 50 million docs. (0) | 2011.06.03 |
Hadoop에서 특정 Datanode만 재시작하는 방법 (0) | 2011.06.02 |