본문 바로가기

Dart

[Dart] Class - Static

void main() {
  // Method overriding
  Student.schoolName = 'Korea';
  Student kim = new Student(1, 'kim');
  kim.who();
}

// 학생, 학교이름, 학년, 학생이름
class Student {
  static String? schoolName;
  int grade;
  String name;

  Student(this.grade, this.name);

  void who() {
    print('I am $name, grade is $grade, school name is $schoolName');
  }
}

--------------------------------------------[result]

I am kim, grade is 1, school name is Korea

'Dart' 카테고리의 다른 글

[Dart] Class - interface  (0) 2021.05.27
[Dart] Class - super, this  (0) 2021.05.27
[Dart] Class - Method override  (0) 2021.05.27
[Dart] Class - 상속/Inheritance  (0) 2021.05.27
[Dart] Class - getter, setter  (0) 2021.05.27