[1]PPT内容来自遇见狂神说
一、方法的定义:
![](https://img-blog.csdnimg.cn/img_convert/1f202c16a19af9550641747bedfcbee5.webp?x-oss-process=image/format,png)
图片内容来自狂神说
二、方法的调用:
![](https://img-blog.csdnimg.cn/img_convert/874a43654d00df0015fec940b3ab7f9c.webp?x-oss-process=image/format,png)
图片内容来自狂神说
三、练习:
(1)
![](https://img-blog.csdnimg.cn/img_convert/6f5e680c3085aca400cff8c4bb239886.webp?x-oss-process=image/format,png)
(2)
![](https://img-blog.csdnimg.cn/img_convert/666b735e90f63656a37bcbd42e50b6ec.webp?x-oss-process=image/format,png)
四、值传递与引用传递
值传递(pass by value):在调用函数时,将实际参数复制一份传递到函数中,这样在函数中对参数进行修改,就不会影响到原来的实际参数;
引用传递(pass by reference):在调用函数时,将实际参数的地址直接传递到函数中。这样在函数中对参数进行的修改,就会影响到实际参数;
五、方法的重载
![](https://img-blog.csdnimg.cn/img_convert/caa90fd9e8623276a94d1155d25f6f22.webp?x-oss-process=image/format,png)
图片内容来自狂神说
![](https://img-blog.csdnimg.cn/img_convert/89494e4e1c2ed120b5d1ec8fdbcee5c9.webp?x-oss-process=image/format,png)
六、命令行传参
靠传递命令行参数给main()函数实现
![](https://img-blog.csdnimg.cn/img_convert/0439342d899f4eaeb461aaef7557ef31.webp?x-oss-process=image/format,png)
如果有错误,请指正。谢谢!!
参考
- ^ppt内容来自狂神说 Java方法02:方法的定义和调用_哔哩哔哩_bilibili