One day to become a few days, recently accepted new things too much, too fast, there are many need to blog but no time, these basic knowledge should be deep digging and study, should not be quickie every time, only to see a fur.
array:
The JVM stores the array in a memory area called the heap, which is used for dynamic memory allocation, where the blocks of memory can be allocated and freed in random order
1.int[] A; --Declares an array (also writable as int a[];)
Declaring an array variable does not allocate any space to the array in memory, just the storage location where the reference to the arrays is created
If the variable does not contain a reference to an array, then the value of the variable is null
Creating an array with the new operator
When using the array initialization syntax, you must put the declaration, creation, and initialization arrays in one statement, as the following code is wrong:
Double= {1, 2, 3};
2. How the array is passed in the method
public static void main (string[] args) { int x = 1< span> int [] y = new int [10 M (x, y); SYSO ( "x is" + x); Syso ( "y[0] is" + Y[0 public void m (int number, int [] numbers) {Number = 10; numbers[ 0] = 10;}
// output:x is 1y[0] is 10
This is because:
For the base data type parameter, the value of the argument is passed
For an array type parameter, the parameter value is a reference to the array, and the reference is passed to the method
3. Enquiry
Two-point query
4. Sorting
Select sort
Bubble sort
Quick Sort
Insert Sort
One day a Java foundation--Array