»ý¼ºÀÚ¸Þ¼µå¸¦ ÀÌ¿ëÇØ ¸â¹ö¸¦ ÃʱâÈÇÏ´Â ¿¹Á¦
ConstructTest.java
public class ConstructTest {
private String name = null;
private String address = null;
private int age = 0;
public ConstructTest() {
this.name = "À̸§¾øÀ½";
this.address="ÁÖ¼Ò¾øÀ½";
this.age=0;
}
public void setList(String sname, String saddress, int sage) {
this.name = sname;
this.address = saddress;
this.age = sage;
}
public String getList() {
String str = name + " " + address + " " + age;
return str;
}
public static void main(String[] args) {
ConstructTest ct = new ConstructTest();
String s;
s = ct.getList();
System.out.println(s);
ct.setList("È«±æµ¿", "¼¿ï½Ã Áß±¸", 25);
s = ct.getList();
System.out.println(s);
}
}
C:\javaExample\04>javac ConstructTest.java
C:\javaExample\04>java ConstructTest
À̸§¾øÀ½ ÁÖ¼Ò¾øÀ½ 0
È«±æµ¿ ¼¿ï½Ã Áß±¸ 25
»ý¼ºÀÚ¸Þ¼µå´Â ÁÖ·Î ¸â¹öµéÀÇ ÃʱâÈ ÀÛ¾÷¿¡ »ç¿ëµÈ´Ù.
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:°´Ã¼°³³ä¼Ò½ºÄÚµå ÀúÀÚ:ÃÖ¿µ°ü |