One day a Java foundation--Array

Source: Internet
Author: User

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

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.