Advertisement
sergAccount

Untitled

Feb 6th, 2021
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app8_dz;
  7.  
  8. import java.util.concurrent.Callable;
  9.  
  10. public class AvgTask implements Callable<Double>{
  11.     private int[] array;
  12.    
  13.     public AvgTask(int[] array){
  14.         this.array = array;
  15.     }
  16.     // выполняем вычисление на основе массива array и возвращаем значение Double
  17.     @Override
  18.     public Double call() throws Exception {
  19.         double res = 0;
  20.         for (int i = 0; i < array.length; i++) {
  21.             res += array[i];            
  22.         }
  23.         return res / array.length;
  24.     }        
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement