Why String is Immutable in Java

In Java, String is immutable because once a String object is created, its state (value) cannot be changed. Any modification to a String…