They are both objects, but Java reuses objects for strings where it makes sense.
[...] Java String Pool — the special memory region where Strings are stored by the JVM.
Thanks to the immutability of Strings in Java, the JVM can optimize
the amount of memory allocated for them by storing only one copy of
each literal String in the pool. This process is called interning.
When we create a String variable and assign a value to it, the JVM
searches the pool for a String of equal value.
If found, the Java compiler will simply return a reference to its
memory address, without allocating additional memory.
If not found, it’ll be added to the pool (interned) and its reference
will be returned.
Source