Skip to content
Justice Tech School

Static Members

static members belong to the class. const constructors make compile time objects.

Example
class Counter {
  static int count = 0;
  Counter() { count++; }
}
void main() {
  Counter(); Counter();
  print(Counter.count);
}

Exercise

Class level.

 int n = 0;

Quiz Test

Where does static live?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.