题目:
定义一个方法,该方法能够找出两个小数中的较小值并返回。在主方法中调用方法进行测试。
我写的代码:
public static void main(String[] args) {
Test test = new Test();
System.out.println(test.getMin(10.2,5.2));
}
public double getMin(double a,double b){
if (a < b){
return a;
}else {
return b;
}
}
代码有可能不是最优解答,如果有大佬也可以把更完美的代码发到评论区,或者给出优化的代码