320x100
// static
void main() {
Employee daniel = Employee('daniel');
Employee chajun = Employee('chajun');
daniel.printNameAndBuilding();
chajun.printNameAndBuilding();
// 제 이름은 daniel입니다. null 에서 근무 하고 있습니다.
// 제 이름은 chajun입니다. null 에서 근무 하고 있습니다.
// static은 아예 그 고유의 변수 값 안에 값을 설정해주는 느낌이다.
Employee.building = '대박타워';
daniel.printNameAndBuilding();
chajun.printNameAndBuilding();
// 제 이름은 daniel입니다. 대박타워 에서 근무 하고 있습니다.
// 제 이름은 chajun입니다. 대박타워 에서 근무 하고 있습니다.
}
class Employee {
// the building where working employee
static String? building;
// employee's name
final String name;
Employee(
this.name
);
void printNameAndBuilding() {
print('제 이름은 $name입니다. $building 에서 근무 하고 있습니다.');
}
static void printBuilding() {
print('저는 $building 건물에서 근무중 입니다.');
}
}
300x250
'개발일지 > 임시카테고리' 카테고리의 다른 글
dart - class generic 다트 - 클래스 제네릭 6 (0) | 2025.03.24 |
---|---|
dart - class interface (abstract, implements) 다트 - 클래스 인터페이스 앱스트랩트, 임플리먼트 사용강제 5 (0) | 2025.03.24 |
dart - class override (다트 - 클래스 오버라이드) 3 (0) | 2025.03.24 |
dart(다트) - class(클래스) 상속 2 (0) | 2025.03.24 |
dart(다트) - class(클래스) 기본 1 (0) | 2025.03.24 |