juniorStrings
What is a String and how is it stored in memory?
Updated Apr 28, 2026
Short answer
A string is a sequence of characters, typically stored as a contiguous array of bytes or integers (Unicode).
Deep explanation
Strings are one of the most common data types. A string is a sequence of characters, typically stored as a contiguous array of bytes or integers (Unicode). Understanding how they are represented (ASCII/UTF-8/UTF-16) is key to solving character encoding issues.
Real-world example
Storing user names or IDs in an application.
Common mistakes
- Modifying a string inside a long loop without using a StringBuilder/StringBuffer.
Follow-up questions
- What is the time complexity of concatenation?