Data Types in Dart Programming Language |
Data Types in Dart Programming Language.
There are basically five data types in Dart programming language:
i) Integer Data Type (int)
ii) Double Data Type (double)
iii) String Data Type (String)
iv) Boolean Data Type (bool)
v) Dynamic Data Type (dynamic)
Note: int, double, String, bool and dynamic all are predefined variables for initializing respective data types in Dart programming language.
The first four data types are Strongly or Fundamental Typed variables i.e, these type of variable is known at compile time as like in Java, C#, etc.
And, the last fifth data type is Dynamically Typed variables i.e, the dynamically typed variables are known at the run time.
-
-
var Keyword:
"var" is also a predefined keyword in Dart. In the Dart programming language "var" keyword is used to automatically understand the data type of the variable according to its initialization in the program.
For example: -
var varName = 100; // Here, varName is treated as integer.
var varName = 'Rohit Kumar'; //Here, varName is treated as String
Example of Dynamic Data Type:
void main() {
dynamic varName = 100;
print(varName);
varName = 'Rohani Sinha';
print(varName);
}
Output:
100
Rohani Sinha
Integer Data Type (int):
Integer Data Type is initialization with the help of "int class" which is predefined class. "int class" is used to define an integer number.
Double Data Type (double):
Double Data Type is initialization with the help of "double class". "double class" is used to define a double-precision floating-point number.
-
-
String Data Type (String):
String Data Type is initialization with the help of "String class". "String class" is used to define a String value.
Boolean Data Type (bool):
String Data Type is initialization with the help of "String class". "String class" is used to define a String value.
Dynamic Data Type (dynamic):
Dynamic Data type of a variable is known at run time.
eg:
dynamic dya = 100; //Prints --> 100
dya = 'Rohani'; // Prints --> Rohani
dya = 10.1; //Prints --> 10.1
Program:
void main() {
dynamic d = 100;
print(d);
d = 'Rohani';
print(d);
d = 10.1;
print(d);
}
Output:
100 Rohani 10.1
100 Rohani 10.1
-
-
---
I hope you likable this nice post. Do not forget to share it together with your friends, the Sharing Button is below the post. Apart from this, if there's any downside within the intermediate, don't hesitate to request the Comment Box. we are going to be happy to help you.
I will continue to write more and more on this blog, so do not forget to make our blog BlogLearner as a bookmark (Ctrl + D) on your mobile or computer and subscribe to us to get all the posts in your email. Do not forget to share these posts, if you like it. You can facilitate us reach additional individuals by sharing it on social networking sites like Facebook or Twitter.
Dart Programming Language |
#dart #dart_programming_language #comments_in_dart_programming_language #rrkksinha #bloglearner
No comments:
Post a Comment