ITPub博客

首页 > IT职业 > IT图书 > 静态类求最大值最小值

静态类求最大值最小值

IT图书 作者:mpsky 时间:2021-09-09 08:55:08 0 删除 编辑
package example;

public class MaxMin {
    public static class Result {
        private double max;
        private double min;
        public Result(double max,double min) {
            this.max=max;
            this.min=min;
        }
        public double getMax() {
            return max;
        }
        public double getMin() {
            return min;
        }
    }
    public static Result getResult(double array[]) {
        double max=Double.MIN_VALUE;
        double min=Double.MAX_VALUE;
        for (double i : array) {
            if(i>max) {
                max=i;
            }
            else
                min=i;
        }
        return new Result(max,min);
    }
    public static void main(String[] args) {
        double array[]=new double[5];
        for (int i = 0; i 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1806/viewspace-2798007/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-07-18

  • 博文量
    115
  • 访问量
    14711