< Java Tutorial

Strings

  • String str = "abc"
  • String str = "abc"+"def"
  • String str = "abc".substring(2,3);
  • charAt
  • concat
  • String.format
  • indexOf
  • length
  • split
  • substring
  • String.valueOf

String builder

In Java, Strings are normally immutable objects - making a change necessitates creating a new String, which will be inefficient if you need to manipulate large amounts of text.

The StringBuilder class is designed for such instances.

The following methods are important for the string builder:

  • append(addition): adds the value to the end of the string.
  • charAt(index)
  • delete(start, end)
  • insert(offset, addition)
  • length
  • replace(start, end, str)
  • toString
This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.