Home > Java > javaTutorial > body text

Arrays de strings

WBOY
Release: 2024-08-13 11:34:02
Original
481 people have browsed it

String arrays

  • 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 initialindex, intfinalindex);

  • 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.

The above is the detailed content of Arrays de strings. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!