Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Java
/
Data types
Why can a Java String containing one displayed symbol have length 2?
from Data types
Java 25 LTS
beginner
1 min
Why can a Java String containing one displayed symbol have length 2?
String.length counts UTF-16 code units, and a supplementary code point uses a surrogate pair.
Every Java character is stored twice for error correction.
String.length includes a terminating null character.
Check
Ask AI about this kata
Report an error
next kata
What does this program print?
Predict the output
A new version is available
Reload