Concept
How are String variables declared and reassigned in Java?
"We can declare String variables and assign them values using the regular assignment operator.\n\n1 String firstName = \"Thomas\";\n\n2 String lastName = \"Waits\";\n\n3 4 //we can also reassign values\n\n5 firstName = \"Tom\";\n\nNote that the reassignment in the last line in the example does not change the original string. It just makes the variable firstName point to a new string. If there are no other references to the old string, it becomes eligible for garbage collection and the JVM takes care of it."
Related Ideas
- How can strings be created and assigned to variables?ComputerScienceOne · Basic Operations
- How are variables declared and assigned in Java?ComputerScienceOne · Declaration & Assignment
- How can you create and reassign strings in PHP?ComputerScienceOne · Basics
- How are arrays of strings used in Java?ComputerScienceOne · Arrays of Strings
- What are PHP strings and how should they be treated?ComputerScienceOne · Basics