Get average speed of fastest five cars 

Classic problem which may show your understanding different ways to solve the problem, using of data types,  knowledge of Java application design, and knowledge of Java 8


Get average speed of fastest five cars on the road.

Solution - ArrayList, Java 8

In a straightforward way, we can create a new ArraListy, will collect car's speed and then return average speed.

import java.util.List;
import java.util.ArrayList;

public class AvarageSpeed{

       private List list = new ArrayList();

       public void addNewCarSpeed(Double speed){
              if (list.size()>5) list.remove(;

       public Double getAverageSpeed(){
             return  list