> For the complete documentation index, see [llms.txt](https://cs4998.cornellblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cs4998.cornellblockchain.org/introduction/hello-world-pt.-2/dynamic-arrays-and-strings/strings.md).

# Strings

Having seen dynamic types in action (via dynamic arrays), it is time that we look at the type that has been absent from our discussion of the Solidity programming language: strings. Like most other programming languages, Solidity allows us to write literal text via strings, which have no size restriction.

As with most programming languages, strings in Solidity are an array of characters (represented by a byte); below is the syntax to declaring a string:

```solidity
string M stringName;
```

where `M` is the location of the string; below are the following locations where a string can be defined:

* `memory`: within the body of a function and as a function parameter
* `calldata`: as a function parameter

Below is a code snippet which uses strings extensively:

```solidity
contract StringExample {

    string name = "John";
    
    function getName() public view returns(string memory) {
        return name;
    }
    
    function setName(string calldata _name) public {
        name = _name;
    }

}
```
