- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String in Dart Programming
A String in dart is a sequence or series of characters. The characters can be - special characters, numbers or letters. In Dart, we can represent strings with both the single quotes and double quotes.
Example
'a string value' or "another string value"
Both the examples are valid examples of a string in Dart.
In Dart, we can declare strings with the help of the String keyword and also we can use the var keyword as well.
Example
Consider the example shown below −
void main(){ String name = "Tuts"; var herName = "Shreya"; print(name); print(herName); }
In the above example, we have declared two strings and both these are valid strings in Dart. It should be noted that one string is declared with the help of the String keyword and the other string is declared with the help of the var keyword.
Output
Tuts Shreya
Note − To print a string in dart, we can simply use the print() function. It prints the formatted message to the terminal, we can pass a string as a message or we can pass a variable as well, both works fine.
Example
Consider the example shown below −
void main(){ String name = "Tuts"; print(name); print("TutorialsPoint"); }
In the above example, we are passing the string to the print() function directly in the second print statement, and in the first case, we simply pass a variable to it, which contains a string value.
Output
Tuts TutorialsPoint
String Concatenation in Dart
String concatenation is the process of adding two strings in Dart. It is usually done with the help of the + operator symbol.
Syntax
str1 + str2;
Example
Let's take an example of string concatenation in Dart, where we add two string values.
Consider the example shown below −
void main(){ String name = "Tutorials"; var anotherName = "Point"; print(name + anotherName); }
Output
TutorialsPoint
It should be noted that we can append space in between them using the " ".
Example
Consider the example shown below −
void main(){ String name = "Tutorials"; var anotherName = "Point"; print(name + " " + anotherName); }
Output
Tutorials Point
- Related Articles
- String Interpolation in Dart Programming
- String Methods in Dart Programming
- String Properties in Dart Programming
- Comments in Dart Programming
- Constructors in Dart Programming
- Enumerations in Dart Programming
- Functions in Dart Programming
- Immutability in Dart Programming
- Inheritance in Dart Programming
- Iterables in Dart Programming
- Lists in Dart Programming
- Loops in Dart Programming
- Maps in Dart Programming
- Methods in Dart Programming
- Mixins in Dart Programming
