Learn
Well done, you’re a reference master now!
The concept of references, especially the nuances of the string
type, can be difficult to understand when they aren’t clearly visible in the code. Let the information sink in and play with some code to check your understanding. Once you get it, this concept will save you dozens of hours of debugging.
Here’s what was covered in this lesson:
- The
String
orstring
type is a reference type - Strings are immutable, which means they cannot be changed after they are created
- Being immutable also means that a
string
reference will always point to the original object, so “modifying” one reference to astring
will not affect other references to it - With the equality operator (
==
), strings are checked for value, not referential, equality - A
string
variable can be unassigned,null
, or empty. Empty strings can be represented byString.Empty
or""
— they’re equivalent
Instructions
If you’d like to read more about the String
operations and methods, the documentation has you covered. We don’t expect you to know anymore than what was covered in this lesson, but it’s here if you’re interested!
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.