Explain difference between String and StringBuilder classes of Java.
String and StringBuilder are both classes in Java that are used to manipulate sequences of characters. However, they have fundamental differences in terms of their immutability, performance, and use cases.
### Immutability:
1. String:
- Strings in Java are immutable, meaning their values cannot be changed after they are created.
- If you want to modify a String, such as concatenating two Strings together, a new String object is created.
- This immutability ensures that once a String is created, its value cannot be altered, providing safety in various operations.
2. StringBuilder:
- StringBuilder, on the other hand, is mutable. This means you can modify the sequence of characters it represents without creating
_______ ___ _________ ______ ____ __________ _______ ____ ______ _____ _____ ______.
_________ ________ _____ _________ _________.
__________ _______ _________ ___ ________ ___.
__________ ____ ____ _______ ______ ________.
__________ _____ ___ _____ _____ ______ _____ _______ _______ ______ ________.
__________ __________ ______ ___ ______ _______ ________.
________ _______ _____ ___ ____ _________ ________ ______ ________ ___.
_______ ______ ______ ____ _____ _________ ______ ______.
_________ ________ __________ _______ _________ _________ _______.
________ ________ ________ ___ _______ ________ __________ _____.
_____ ________ _____ __________ ___ _______ _________ ___.
___ _____ _____ _________ _____ _____ _____ ___ __________ ___ _____ _________.
_________ ______ _________ ____ ____ ____.
_______ ____ ________ ___ _____ ____ _______ _______ ______ _________ ___.
_________ ___ ____ ____ _______ _____.
______ ____ _____ ___ ________ ______ ___.
_______ _________ __________ _________ _________ ____ ______ _________ ______ __________ ______.
______ ___ ___ ___ __________ ________ ________ ______ __________ _______ __________.
______ ________ ____ ___ ____.
______ __________ _________ _________ ___ _____ _______ ______ ______ ____ ______.
_________ ________ ___ _______ ________ _______ _______ ________ _____ ___.
____ ________ ___ _________ __________ ______ _______ _____ _______ _____ _________.
________ ____ __________ ____ ________.
____ ___ ______ ______ ___.
_______ _______ __________ __________ ___ __________ _______ _______ _________ ________ ___.
___ __________ _____ _____ __________ ________ _____.
________ ________ __________ _________ __________ ______ __________ _____ ____.
_________ ___ _________ _______ _________ ______.
_______ _________ __________ _______ _________ _______ __________ _______ _____ ____ __________ __________.
_________ _____ _________ ___ _____ __________ _______ _______ ________ ______ _____.
_________ _________ ____ ________ __________ _________ _________.
_____ _________ ____ ________ ____.
__________ _______ ___ _________ __________ __________ __________ _________ ____ ________ _____ __________.
____ ______ _________ _______ _____ ____ ___ ______ ______ _________ ___ _____.
____ ______ _____ ______ ____ ______ ____ ____ ______ ___.
___ ______ _____ _________ ______ ____ _______ _______.
______ ____ _____ ________ ___ ______ ________ _________ ______.
_________ ___ ____ __________ ______.
__________ _________ ___ __________ _____ ________ _______ __________ __________ ________.
____ _________ ________ ______ ________ _____ ____ ______ __________ _______ _____ _______.
__________ _______ __________ ________ ___ _____ __________ _____ ____ ___ _____ _________.
___ ____ ____ _________ ______ ___ ____.
___ _____ _________ _______ ___ ___ __________ ________ ____ _________ _______.
_____.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required