Acquaintance array

1 What is an array

  An array is a container can store a set of data (for the same type)

2 How to bloom?

     According to store the index data (zero-subscript)

3 How to define an array

   Data Type [] array name = initial value

Here type refers to the type of data stored in the array elements

 

Arrays are reference types

In order to get the address of the original data operations


4 defines an array of three ways

      When using an array of unknown content

   1 int [] arra1 = new int [3]; // 3 shows a longitudinal array

   In the definition of the array simultaneously and then the value of element acquaintance

   2 int [] array2 = new int [] {1,2,3,4,5}; // {} represents the value in the array element is

   3 int [] array3 = {1,2,3,4,5}; // 2 is shorthand

New keyword indicates that open up a space in the heap memory

Using the array [i]; angle to access the target element (i is the subscript of the array)

Errors often occur array 5

ArrayIndexOutOfBoundsException array bounds exception

lang.NullPointerException null pointer exception essay space block does not exist in the

 

 

Function can only be defined in a class can not be defined in a function to go

Guess you like

Origin blog.csdn.net/weixin_40873693/article/details/78493279