作业 关于函数的

public class Test02 {
public static void main(String[] args) { //函数

	// 函数调用的时候传递的参数叫实际参数
	int a1 = 100;
	int a2 = 200;
	int max = a1;
	if (max < a2) {
	max = a2;
	}
	
	hello();
	System.err.println("bye");
}
//可以完成特定功能的代码块,并且能重复调用
//返回值  函数名  参数列表  函数体
public static void hello() {
	System.out.println("hello");
}

public static void println(int x) {
	System.err.println(x);
}

public static double PI() {
	return 3.1415926;
}

//定义函数的时候,参数叫型=形参数
public static int max(int x1, int x2) {
	if (x1 > x2) {
		return x1;		
	}
	return x2;	
}
//函数名相同,参数不同,函数重载overload
//函数名可以相同,但参数不能也相同
//函数的的签名,(参数类型)  max(float, float)
//函数的签名不能相同
public static float max1(float x1, float x2) {
	if (x1 > x2) {
		return x1;
	}
	return x2;
} 
public static float max(float y1, float y2) {
	if (y1 > y2) {
		return y1;
	}
	return y2;
}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值