String

A string is a data type used to represent text.

It is a sequence of characters enclosed in quotation marks.

Why strings are important

Strings are used to:

  • Display messages

  • Store names and text
  • Work with user input
  • Handle data like emails, passwords, and addresses

Almost every program uses strings.

 

How strings look

Strings are written inside quotes.

 

Example:

"Hello"
'Welcome'

Both represent text values.

String variable

You can store a string in a variable.

name = "Alice"

Now the variable name contains text.

String concatenation

You can store a string in a variable.

name = "Alice"

Now the variable name contains text.

String concatenation

Strings can be combined.

"Hello " + "World"

Result → "Hello World"

 

Example with variable:

greeting = "Hello " + name

String length

Many languages allow you to check how long a string is.

 

Example:

length("Hello")

Result → 5

Strings vs Numbers

Important difference:

"5" + "3" → "53" 5 + 3 → 8

Text values behave differently from numbers.

Why learning strings matters

Understanding strings helps you:

  • Work with text data
  • Display dynamic content
  • Process user input
  • Build real-world applications

Most software interacts with users through text.

Simple example

Think of a string like a word written on paper. It’s not a number — it’s text made of characters.

Related terms

Source

Simplified from general programming documentation and Wikipedia.

Nach oben scrollen