A string is always a primitive unless you create it in a…
““A string is always a primitive unless you create it in a special way using an object constructor. We’ll talk about object constructors later. And you can always use the typeof operator on your variable to see if it is of type string or object.””
About This Quote
This interpretation was drafted with AI assistance. It is one reading of the quote, not the author's own explanation.
Primitive strings are the default; using a constructor creates a String object, which can be distinguished with typeof.
In simple terms: Default strings are primitives; constructors make objects.
Use typeof to check string type.
Themes
Mood
Type
When to use this quote
- debugging
- teaching Java
- code reviews
Key Concepts
Questions to Reflect On
- When should you prefer a String object over a primitive?
- What bugs arise from type confusion?
Objects have extra overhead and behave differently than primitives.