¼Ò½ºÄÚµå¶óÀ̺귯¸®  °´Ã¼ÁöÇâ  thisÀÚü  

this°¡ ¾ðÁ¨°¡ »ý¼ºµÉ °´Ã¼ ÀÚü¸¦ ³ªÅ¸³»´Â ¿¹Á¦

SpercialThis.java

public class SpecialThis {
  
private int i = 0
;
  
public void 
plusCount(){ 
    i++; 
  }
  
public 
SpecialThis getMySelf() {
    
return this
;
  }
  
public void 
print(){ 
    System.out.println(
"member i = " this
.i); 
  }
  
public static void 
main(String args[]) {
    SpecialThis st = 
new 
SpecialThis();
    SpecialThis st2 = st.getMySelf();
    st.print();
    st.plusCount();
    st.print();
    st2.plusCount();
    st2.print();
    st.plusCount();
    st.print();
  }
}

C:\javaExample\04>javac SpecialThis.java
C:\javaExample\04>java SpecialThis
member i = 0
member i = 1
member i = 2
member i = 3

thisŰ¿öµå¸¦ ÅëÇØ µðÀÚÀΠŸÀÓ¿¡ ³ªÁß¿¡ »ý¼ºµÉ ÀÚ±â ÀÚ½ÅÀ» ÂüÁ¶ÇÏ°Ô ÇÒ ¼ö ÀÖ´Ù.



jabookÀúÀÚ¸íÇÔ
Á¦¸ñ:°´Ã¼°³³ä¼Ò½ºÄÚµå
ÀúÀÚ:ÃÖ¿µ°ü