日记2017/4/26
来源:互联网 发布:大数据微营销公司 编辑:程序博客网 时间:2024/05/29 19:48
2017.4.26
方法声明定义与重载
public static 返回值类型 方法名称 (类型 参数1,类型,参数2, ...){
程度语句;
return **
}
例子:
public static int addone(int a,int b){int temp=0;temp=a+b;return temp;}public static void addone(int a,int b){int temp=0;temp=a+b;System.out.print("temp="+temp);}
无返回值return 时要用void ,重载为方法中参数数量类型不同,单独定义(addone(1,2)与addone(1,2,3))
可以使用return直接结束方法执行
public static void fun(int x){System.out.println("1.进入fun()方法");if(x==10){return;}System.out.println("2.正常执行完fun()方法")}
如果调用fun()方法中x==10就只会执行1.不会执行2.
public static void fun(int...arg){ //可变参数,可接收任意多少参数for(int x:arg){ //使用foreach语法代替for(int i =0,i<arg.length;i++)System.out.print(x+"、"); } }
0 0
- 日记2017/4/26
- 2017年4月26日工作日记
- 日记4
- C#学习日记2011-4-26
- 2017年4月-学习日记
- 2015.1.26实验室日记
- 日记2016.4.26
- 工作日记2017.07.26
- 2017.07.26工作日记
- 2017.09.26工作日记
- 训练日记-26
- 2017.10.26工作日记
- TensorFlow学习日记26
- [日记] 2017年 Ⅲ
- 日记2017,12,17
- 日记2017,12,20
- 日记2017-12-23
- 4月4日记
- Android 自定义Gson格式
- maven下载速度太慢(换成阿里云的maven中央仓库)
- ZFS 池损坏恢复
- scala sparkstreaming wordcount
- JS处理字符串---正则表达式和String类
- 日记2017/4/26
- PASSTHRU and NOPASSTHRU are deprecated on OGG 12.2.0 (Doc ID 2222942.1)
- Centos 下开机启动Tomcat
- 折半排序
- SAP 项目管理PS与Oracle P6对比- 多用户性和使用方便 2/5
- oracle分组,排序,函数,dml,ddl,约束,运算符
- Installation of GMT5 and GMT5SAR
- 程序员的法宝 – GitHub(二)
- 禁止浏览器的返回