By Enrico Brambilla


2019-11-08 14:03:33 8 Comments

I have to convert this function from Java 8 to Java 7

List<LinkBackofficeServiziBean> linkBackofficeServiziBeans = servizi.stream()
                    .map((Integer servizio) -> new LinkBackofficeServiziBean(servizio,userId))
                    .collect(Collectors.toList());

1 comments

@Elliott Frisch 2019-11-08 14:07:41

Java 7 does not have lambdas, easiest way I can see to port this to Java 7 is to instantiate the List then use a for-each loop to populate it. Something like,

List<LinkBackofficeServiziBean> linkBackofficeServiziBeans = new ArrayList<>();
for (Integer servizio : servizi) {
    linkBackofficeServiziBeans.add(new LinkBackofficeServiziBean(servizio,userId));
}

Related Questions

Sponsored Content

85 Answered Questions

[SOLVED] Is Java "pass-by-reference" or "pass-by-value"?

41 Answered Questions

[SOLVED] How do I efficiently iterate over each entry in a Java Map?

43 Answered Questions

[SOLVED] How do I convert a String to an int in Java?

65 Answered Questions

[SOLVED] How do I generate random integers within a specific range in Java?

  • 2008-12-12 18:20:57
  • user42155
  • 3900041 View
  • 3359 Score
  • 65 Answer
  • Tags:   java random integer

55 Answered Questions

[SOLVED] Creating a memory leak with Java

57 Answered Questions

[SOLVED] How do I read / convert an InputStream into a String in Java?

18 Answered Questions

[SOLVED] Converting array to list in Java

51 Answered Questions

[SOLVED] Sort a Map<Key, Value> by values

14 Answered Questions

[SOLVED] How can I pad an integer with zeros on the left?

13 Answered Questions

[SOLVED] Java string to date conversion

Sponsored Content