Arrays of strings
Strings cannot be changed
The content of a String object in Java is immutable; once created, it cannot be changed.
This immutability allows Java to implement strings more efficiently.
To create a variation of a String, you need to create a new String object.
Unused strings are automatically collected by the garbage collector.
Although the contents of a String are immutable, reference variables can change to point to other objects.
String substring(int initial index, in final index);
The substring() method exemplifies immutability, returning a new String without changing the original.
Program output:
orgstr: Java makes the Web move.
substr: makes the Web.
Original string orgstr remains unchanged and substr contains the substring.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3