juniorJava

What is String in Java?

Updated May 6, 2026

Short answer

String is an immutable class used to represent text.

Deep explanation

Strings are stored in string pool. Once created, they cannot be modified, ensuring memory efficiency.

Real-world example

Used in usernames, messages, and logging systems.

Common mistakes

  • Using == instead of equals() for comparison.

Follow-up questions

  • Why is String immutable?
  • What is string pool?

More Java interview questions

View all →