```
public class Solution {
public double findMaxAverage(int[] nums, int k) {
int sum = 0;
for(int i = 0;i<k;i++){
sum += nums[i];
}
int maxAvg = sum;
int index = 0;
for(int i = k;i<nums.length;i++){
sum -= nums[index++];
sum += nums[i];
maxAvg = Math.max(maxAvg, sum);
}
return (double)maxAvg / k;
}
}
```