Home  >  Article  >  Java  >  Arrays de strings

Arrays de strings

WBOY
WBOYOriginal
2024-08-13 11:34:02552browse

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!

Statement:
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