DART  Static

// to make any variable universal for all object belongs to that class

// static is also applied to method of class

// static work without any constructor

int main(){

// Square myShape = Square(); not need constructor static
int side = Square.noOfSide;
print(side);

// Circle().getOurCircumference(radius: 20); // without static
Circle.getOurCircumference(radius: 20); // with static, call by this

// static work without any constructor as we seen above
}

class Square{
static int noOfSide = 4;
}

class Circle{

static const double pi = 3.1415926;

static void getOurCircumference({double radius}){
double circumference = 2 * pi * radius;
print(circumference);
}
}





















Comments