Java Programming Fundamentals stage notes day05 array

Array

Notes Notes

  • Array Introduction

  • Array Declaration

  • Array initialization

  • The default value of array elements

  • Copies the array

  • Array reverse

  • Find arrays: linear search, binary search

  • Array Sort: Bubble Sort

 

  • Array Introduction

    • Array name: Create an array of memory in a block of contiguous open space, and the name of the array is the first address referenced in this continuous space.

    • Index (or index): from 0

    • An array is a reference to member variable data types, elements equivalent to class,

    • An array of allocated space, wherein each element is also implicitly initialized in the same manner as member variables

    • Elements in the array may be a base data type may be reference data types

  • Array Declaration

    • Disclaimer: String [] names;

    • int scores[];

  • Array initialization: static initialization, dynamic initialization

    • Static Initialization: Initialization and assignment of the array are simultaneously

    • names = new String{"12","34","56","78"};

    • Dynamic Initialization: Initialization and array-valued separately

    • String[] names2 = new String[5];

    • names2[0] = "123";

    • Declare and initialize an array of ways following can not be separated.

                      int[] age = { 1, 2, 3, 4, 5, 6 };

  • The default value of array elements

    • byte、short、int、long  -->0

    • float、double --->0.0

    • bolean --> \u0000

    • Reference data types (classes, arrays, interfaces) ---> null

  • One-dimensional array of memory parsing

    • String[] persons = new String[3];

    • String[] persons2 = persons;

    • // persons and persons2 actually point to the same piece of memory

  • Heap, stack, method area

    • Heap (heap): used to store the object instance, as long as the new pile out in

    • Stack (stack): storing the local variables, such as the basic data types, object reference (reference type, it is not equivalent to the object itself, is the first address of an object in the heap memory)

    • 方法区(Method Area):用于存储已被虚拟机加载的类信息、常量、静态变量、即时编译器编译后的代码等数据。

 

总结Summary

  • 静态初始化与动态初始化

  • 数组反转

  • 数组查找:二分查找

  • 数组排序:冒泡排序

Guess you like

Origin www.cnblogs.com/bigdatahub/p/11278632.html