学习记录Day2(Learning record Day2)

Java方法详解

方法重载
方法名需同,形参需不同
返回类型都可
编译器会根据调用方法的参数个数,类型匹配对应的方法

可变参数

递归

一般小规模
空间复杂度高

数组

定义:类型[] 数组名 = new 类型[大小]

内存分析

  • 方法区
    目前简单了解概念

初始化

  • 静态:int[] a = {1,2,3,4};
  • 动态:int[] b = new int[10]; 包含默认初始化
    数组是一个对象,数组元素相当于对象的成员变量

for-each循环

无下标,不能操作成员

Arrays类

常用方法:

  • fill
  • sort
  • equals
  • binarySearch

稀疏数组存储

行数 列数 有效值数
x y 有效值
…… …… ……
————————

Detailed explanation of Java methods

Method overloading
The method name must be the same and the formal parameters must be different
All return types are allowed
The compiler will match the corresponding method type according to the number of parameters calling the method

Variable parameters

recursion

Generally small scale
High spatial complexity

array

Definition: type [] array name = new type [size]

Memory analysis

  • heap
  • Stack
  • Method area
    At present, we have a simple understanding of the concept

initialization

  • Static: int [] a = {1,2,3,4};
  • Dynamic: int [] B = New Int [10]; Include default initialization
    An array is an object, and the array elements are equivalent to the member variables of the object

for-each循环

No subscript, cannot operate on member

Arrays类

Common methods:

  • fill
  • sort
  • equals
  • binarySearch

Sparse array storage

行数 列数 有效值数
x y 有效值
…… …… ……