The JVM (Java Virtual Machine) is an abstract machine
that runs Java programs, enabling them to be platform-
independent ("Write Once, Run Anywhere") by
interpreting compiled Java bytecode into native machine
code for any operating system
Scanned with
class array string interface enum collectors
ECG3
StringBuffer ClassStringBuffer is a class that allows us to create
and modify a flexible, expandable sequence of characters. It is
thread-safe. Thismeans that it can be safely used when multiple
threads are accessing or modifying the string concurrently. But
due to synchronization, it is slower than StringBuilder.
StringBuilder ClassStringBuilder is similar to StringBuffer,
but it is not synchronized. Thismeans it is not thread-
safe. But it is much faster than StringBuffer and is
suitable for use in scenarios where thread safety is not
required (e.g., competitive coding, interview questions).
Java stores frequently used string literals in a special
memory area called the "String Constant Pool" (SCP) to
save heap space and improve performance. If strings were
mutable, a change made through one reference would
affect all other references pointing to the same object in the
pool, leading to unpredictable behavior and data
corruption. Immutability guarantees that shared objects
remain consistent.