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

ÀÚ½ÅÀ» ÂüÁ¶ÇÏ´Â °´Ã¼º¯¼ö this¸¦ ÀÌ¿ëÇÏ¿© ¸â¹ö¸¦ ÀÌ¿ëÇÏ´Â ¿¹Á¦

 ThisTest.java

public class ThisTest {
  
private int 
number;
  
private 
String name;
  
public ThisTest(String name, int 
number) {
    
//this¸¦ ÀÌ¿ëÇÑ ¸Å°³º¯¼ö¿ÍÀÇ ±¸ºÐ
    
this
.name = name;
    
this
.number = number;         
  }
  
public void 
print(){
    System.out.println(
"-- this¸¦ ÀÌ¿ëÇÑ ¸â¹ö Å×½ºÆ®---"
);
    System.out.println(
"name:" this.name + " number:" this
.number);                  
  }
  
public void 
myprint(){
    System.out.println(
"-- this¸¦ ÀÌ¿ëÇÑ ¸Þ¼­µå Å×½ºÆ®---"
);
    
this
.print();
  }
  
public static void 
main(String[] args) {
    ThisTest th = 
new ThisTest("È«±æµ¿"20
);
    th.print();
    th.myprint();                   
  }
}

C:\javaExample\04>javac ThisTest.java
C:\javaExample\04>java ThisTest
-- this¸¦ ÀÌ¿ëÇÑ ¸â¹ö Å×½ºÆ®---
name:È«±æµ¿ number:20
-- this¸¦ ÀÌ¿ëÇÑ ¸Þ¼­µå Å×½ºÆ®---
-- this¸¦ ÀÌ¿ëÇÑ ¸â¹ö Å×½ºÆ®---
name:È«±æµ¿ number:20

this¸¦ ÀÌ¿ëÇØ¼­ ³ªÁß¿¡ »ý¼ºµÉ °´Ã¼ÀÇ ¸â¹öµéÀ» È£ÃâÇÒ ¼ö ÀÖ´Ù.



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