String class:
1. for the Equality judgment of a string object, use the Equals () method instead of = =. The Equals () of string determines whether the current string is consistent with the contents of the passed-in string.
2. string is a constant, and its object cannot be changed once it has been created. When using the + stitching string, a new string object is generated instead of appending content to the original string object.
3. string pool is in stack memory.
4. String s = "AAA"; (value is assigned in literal form)
1). Look for the "AAA" object in the string pool, create an "AAA" object in the string pool if it does not exist, and then return the address of the "AAA" object in the string pool to the reference variable Volume S,
So s will point to this "AAA" string object in String Pool
2). If present, do not create any objects, directly return the "AAA" object address in the String Pool and assign it to the S reference.
5. string s = new string ("AAA");
1). First find the String object in the string pool that has no "AAA ", and if so, do not create an "AAA" object in the string pool, directly create an "AAA" string object in the heap (heap). /c7>
The address of the "AAA" object in the heap is then returned to the S reference, causing S to point to the "AAA" string object created in the heap.
2). If not, first create an "AAA" object in the String Pool, then create an "AAA" object in the heap (heap), and then return the address of the "AAA" object in the heap to the s reference, causing S to point to
The "AAA" object created in the heap.
6. Note the encoding format when working with strings, and convert the binary to a string to consider the construction method: New string (byte[] bytes, string charsetname)
Array Arrays:
1. define several formats for the array:
1). type[] Variable name = new type[The number of elements in the array];
2). Type variable name [] = number of elements in the new type[array];
3). Type variable name [] = new type[]{comma-delimited list of initialization values};
4). Type variable name [] = comma-separated list of initialization values};
2. the element index in the array starts at 0. For arrays, the maximum index = = array Length-1.
3. each array in Java has a property named Length, which represents the size of the array. The property of length is Public,final,int. Once an array is determined, it cannot change size.
4. int[] A = new int[10], where a is a reference that points to the first address of the generated array object.
5. for native data types, the data values are stored in the array. For reference types, the array holds the value of the reference type, not the object itself.
6. a two-dimensional array is a planar two-dimensional structure, essentially an array of arrays. How two-dimensional arrays are defined: type[][] a = new type[][], etc.
7. Three- dimensional array definition mode: type[][][] A = new type[][][]
The main content of this article is from Santhiya Garden notes
Java SE Basics (String,array)