Java 8 shows this error. Local variable itemList defined in an enclosing scope must be final or effectively final
问题 I am writing the code using java 8 but I iterate a List and then find RestaurantOrderBook using category type. and put that List into a Map . it shows this error: Local variable itemList defined in an enclosing scope must be final or effectively final Query query = new Query(); String categ = category; query.addCriteria(Criteria.where("restaurantId").is(restaurantId)); List<RestaurantOrderBook> itemList = new ArrayList<RestaurantOrderBook>(); itemList = mongoTemplate.find(query,