8.Java String Overview

Source: Internet
Author: User

The string from the surface, is the data between the quotation marks, such as "www.weixueyuan.net", "micro-school", "C + + Introductory tutorial" and so on. In Java, the string processing class library uses the most of the two types:the "string" Class and the "StringBuffer" class .

Note: If you are working with some small text, it is recommended to use the "String" class, which is particularly handy. If you use the String class to work with large text, you consume system resources, so the Java programming language specifically introduces the "StringBuffer" class.

The "string" string has one thing in common with the array learned in the previous chapter. Is that they are initialized, the length is constant, and the content is unchanged. If you want to change its value, a new string is generated, as follows:
String str1= "very";
str1=str1+ "Good";
This assignment expression looks a bit like a simple solitaire. Add a "good" string immediately after "str1" to form the final string "very good". It works like this: The program first produces a "str1" string object and requests a space in memory. It is not possible to append a new string, since the string is initialized and the length is fixed. If you want to change it, only discard the original space, re-apply to accommodate "very" and "good" two strings of memory space, and then put the "very good" string into memory.

Here is a simple introduction to the string, the simplest way to declare a string. Other operations on strings are explained in detail when it comes to the "string" Class and the "StringBuffer" class.

8.Java String Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.