方法1
用stream流
List<OctvParkCamera> parkCameraList = octvParkCameraMapper.selectOctvParkCameraList(octvParkCamera);
List<OctvParkCamera> newList=parkCameraList.stream().limit(4).collect(Collectors.toList());
方法2
if (parkCameraList.size() > 4) {
List<OctvParkCamera> newList = parkCameraList.subList(0, 4);
return newList;
} else {
return parkCameraList;
}