标签:sub fun result ase tor stat ring function ati
class ArithmeticFunction {
public static int arithmetic(int a, int b, String operator) {
int result=0;
switch(operator){
case "add":
result=a+b;
case "subtract":
result=a-b;
case "multiply":
result=a*b;
case "divide":
result=a/b;
return result;//语句放这里才有效
}
return result;//语句放这里是无效的,result的值就为0
}
}
标签:sub fun result ase tor stat ring function ati
原文地址:https://www.cnblogs.com/aurora-cj/p/8929905.html