💻 Computer Science · Topic 24 of 80

Strings

Strings are sequences of characters.

Interactive labFollow the idea step by step

About this topic

A string is a sequence of characters used to store text, such as a name, a sentence or a password. Strings are written in quotes, and each character has a position called an index, usually starting at 0. Common operations include finding the length, joining (concatenation), slicing out pieces, searching, and changing case.

For the string hello, the length is 5, the first character at index 0 is h, and the last at index 4 is o. Joining Good and morning gives Good morning. Many languages treat strings as immutable, meaning you cannot change a character in place but must make a new string. Escape characters such as backslash n create a new line.

Strings drive search boxes, messages, file names and data processing. A classic task is checking for a palindrome, a word that reads the same backwards, like level. A common mistake is forgetting that the character 7 is not the number 7, so you must convert before doing arithmetic. Another is counting positions from 1 instead of 0, which causes off-by-one errors. Always check the first and last index.

Key ideas

  1. Concatenate with +
  2. Index from 0
  3. Methods like upper() and split()

Quick check

Use cases: where Strings helps

Computing ideas run phones, search engines, games and the wider internet.

Frequently asked questions

What is Strings?

Strings are sequences of characters.

What will I learn in Strings?

Concatenate with +. Index from 0. Methods like upper() and split().

Is Strings part of Computer Science?

Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.

Does the Strings lab work on a phone or tablet?

Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.

How should I study Strings?

Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.

Do I need an account, and is my progress saved?

No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.

More in Computer Science