To declare a string array in Swift, you can use array literal syntax or the Array constructor to create an array with string elements.
In this example,
stringArray
using array literal syntax with predefined string values.var stringArray = ["Hello", "World", "Swift"]
print("String Array: \(stringArray)")
String Array: ["Hello", "World", "Swift"]
In this example,
emptyStringArray
using the Array constructor without any elements.var emptyStringArray = [String]()
print("Empty String Array: \(emptyStringArray)")
Empty String Array: []
In this tutorial, we learned How to Declare a String Array in Swift language with well detailed examples.