객체 생성, 생성자 호출
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package Lecture8;
public class Dog {
String name;
int age;
Dog(){}
Dog(String n, int a){
name = n;
age = a;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package Lecture8;
public class DogMain {
public static void main(String[] args) {
Dog d = new Dog();
d.name = "쫑";
d.age = 3;
Dog d2 = new Dog("메리", 4);
}
}