Questions about the characters and strings encountered by beginners in writing a topic in Java

Source: Internet
Author: User

I saw a good blog:

78738512

1. First of all, in Java, there is no GetChar () like the C language (), that is, Java cannot read a character, it must be treated as a string and read in with Next (). 2. Immutable objects: There is a string type, that is, after the object is created, the object is immutable. It can be said that if an object cannot change its state after it has been created, then the object is immutable. Cannot change the turntable means that you cannot change the member variables within an object, including the value of the base data type cannot be changed, a variable of the reference type cannot point to another object, and the state of the object pointed to by the reference type cannot be changed. A string constant pool is a special storage area in Java heap memory, and when a string object is created, if the string value already exists in the constant pool, a new object is not created, but the object that already exists is referenced.  The code is as follows: String S1 = "ABC";     String s2 = "ABC"; In Java memory is divided into heap memory and stack memory, heap memory is the object, stack memory storage object reference, the string "ABC" is stored in the heap memory, and S1,S2 as the object reference is stored in the stack memory.
  1. Public Final class String
  2. Implements Javaio. serializable, comparable< string >, charsequence
  3. {
  4. Private Final char value[];
  5. Private final int offset;
  6. Private Final int count;
  7. private int hash; columns such as: string string = "ABCDEFG"; String.charat (2) = ' l '; this is wrong.

Questions about the characters and strings encountered by beginners in writing a topic in Java

Related Article

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.