"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Arrays de strings

Arrays de strings

Published on 2024-08-14
Browse:183

Arrays of strings

  • Strings can be gathered into arrays.

Arrays de strings

  • Program output: Original array: This is a test. Modified array: This was a test, too!

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.

Arrays de strings

  • Program output:
    orgstr: Java makes the Web move.
    substr: makes the Web.

  • Original string orgstr remains unchanged and substr contains the substring.

Release Statement This article is reproduced at: https://dev.to/devsjavagirls/arrays-de-strings-5388?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

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