编程语言
首页 > 编程语言> > JAVA走神不认真听课的第四天

JAVA走神不认真听课的第四天

作者:互联网

## 1.5方法详解

### 1.5.1什么是方法

![image-20210208025844038](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208025844038.png)

main方法应该尽量简洁

### 1.5.2方法的定义和调用

![image-20210208032455426](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208032455426.png)



```java
package DAY3;

public class 比大小 {
    public static void main(String[] args) {
        int max = max(10, 20);
        System.out.println(max);
    }

    //比大小
    public static int max(int num1,int num2){
        int result=0;
        if (num1==num2){
            System.out.println("相等");
            return 0;
        }

        //return o 是终止
        if (num1 > num2){
            result=num1;
        }
        else{
            result=num2;
        }
        //一般在外面return
        return result;
    }

}
```

![image-20210208034728417](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208034728417.png)

java都是值传递

### 1.5.3方法的重载

![image-20210208034945344](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208034945344.png)

### 1.5.4命令行传递参数

![image-20210208035249703](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208035249703.png)

### 1.5.5可变参数

![image-20210208035559177](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208035559177.png)

不是很懂

### 1.5.6递归——重难点,笔试面试常出现

a方法自己调用自己

![image-20210208040029596](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208040029596.png)

阶层可以用递归自己调用自己算

java是栈运算,尽量不用,可能会影响性能

## 1.6数组详解

![image-20210208040956390](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208040956390.png)

### 1.6.1数组定义

![image-20210208041159785](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208041159785.png)

### 1.6.2数组的声明和创建

![image-20210208041249128](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208041249128.png)

![image-20210208041644482](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208041644482.png)

![image-20210208041800981](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208041800981.png)

### 1.6.3三种初始化和内存分析

![image-20210208041916515](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208041916515.png)

![image-20210208042755979](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208042755979.png)

静态

![image-20210208042827513](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208042827513.png)动态



### 1.6.4下标越界和小结

![image-20210208043046997](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043046997.png)

![image-20210208042950476](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208042950476.png)

### 1.6.5数组的使用

![image-20210208043817714](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043817714.png)

![image-20210208043448385](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043448385.png)

![image-20210208043610010](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043610010.png)

![image-20210208043736563](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043736563.png)

### 1.6.6二维数组

![image-20210208043850482](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208043850482.png)



![image-20210208044232836](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208044232836.png)



### 1.6.7arrays详解

![image-20210208044410777](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208044410777.png)



?????不懂,好像就大概是一类,然后可以使用,自己也可以写

### 1.6.8冒泡排序

![image-20210208045617123](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208045617123.png)

![image-20210208050230146](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208050230146.png)



### 1.6.9稀疏数组

![image-20210208050446970](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208050446970.png)

![image-20210208050710838](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208050710838.png)

![image-20210208051032379](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208051032379.png)

![image-20210208051220483](C:\Users\hp\AppData\Roaming\Typora\typora-user-images\image-20210208051220483.png)

 

今天没认真听讲,开始怀疑我学这玩意的意义……Python它不香嘛,这个好麻烦,但又不想三天打鱼。

 

标签:JAVA,AppData,image,typora,走神,images,听课,hp,png
来源: https://www.cnblogs.com/qifen2021/p/14387486.html