String is a group of order characters enclosed in double quotes. Swift contains inbuilt data type String to declare and store the collection of characters.

String in a swift is a collection of unicode values.

How to create a String in Swift

There are multiple ways to create a string in swift.

  • Use String Literal

String can be created like a normal variable using var or let keywrod and initialized using string literal syntax. These also called string constant literals.

var name="John";
print (name)
  • using String constructor

Swift provides string constrcutor that accepts string value.

var  name1=String("Mark");
print (name1)
  • using multiline string syntax multi line strings are created using strings that span in multiple lines enclosed in three double quotation marks.
import Foundation
var  multiLineString="""
This is multi line string example
print (multiLineString)