Dart: Object

StateDescribes the object. The fields of a class represent the object’s state.
BehaviorDescribes what an object can do.
IdentityA unique value that distinguishes an object from a set of similar other objects. Two or more objects can share the state and behavior but not the identity.

The Cascade operator

Example

class Student { 
   void test_method() { 
      print("This is a  test method"); 
   } 
   
   void test_method1() { 
      print("This is a  test method1"); 
   } 
}  
void main() { 
   new Student() 
   ..test_method() 
   ..test_method1(); 
}

=> output

This is a test method 
This is a test method1

The toString() method

void main() { 
   int n = 12; 
   print(n.toString()); 
} 

=> output

12

Leave a Reply

Your email address will not be published. Required fields are marked *