Notice
                              
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                            Link
                            
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
                            Tags
                            
                        
                          
                          - 클래스
- JavaScript
- JSP
- Android
- 국제화
- 어노테이션
- Menu
- 안드로이드
- layout
- Eclips
- Spring
- 이클립스
- 생성자
- 에러페이지
- 오버로딩
- Graphic
- OGNL
- 전화걸기
- AWT
- oracle
- struts2
- 예외처리
- mybatis
- 기본
- 메서드
- 메소드
- paint
- Java
- 배열
- HTML
                            Archives
                            
                        
                          
                          - Today
- Total
note
참조 호출 call by reference 본문
class MyDate{//참조 호출 call by reference
	int year=2006;
	int month=4;
	int day=1;
}
class RefMethod{
	void changeDate(MyDate t){
		t.year=2007; t.month=7; t.day=19;
	}
}
public class MethodTest09 {
	public static void main(String[] args){
		RefMethod rm = new RefMethod();
		MyDate d=new MyDate();
		//각 각 클래스 메모리에 올리기
		System.out.println("함수 호출전 d-> "+d.year+"/" +d.month+ "/" +d.day);
		rm.changeDate(d);
		//주소를 MyDate t로 넘기기
		//t는 MyDate클래스의 안에 객체로 넘어감
		//int대신 MyDate가 오면 참조자료형이 오면은 값이 아닌 주소가 오게됨
		System.out.println("함수 호출전 d-> "+d.year+"/" +d.month+ "/" +d.day);
	}
}
함수 호출전 d-> 2006/4/1
함수 호출전 d-> 2007/7/19
'자바 > 생성자' 카테고리의 다른 글
| 생성자 정의하기 (0) | 2011.12.16 | 
|---|---|
| 생성자 은닉화 캡슐화 (0) | 2011.12.16 | 
| 생성자 정의와 호출 (0) | 2011.12.16 | 
| 인자 전달 방식 값 호출 call by value2 (0) | 2011.12.16 | 
| 인자 전달 방식 참조 호출 call by reference (0) | 2011.12.16 |