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 =
                    .map((Integer servizio) -> new LinkBackofficeServiziBean(servizio,userId))


@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

87 Answered Questions

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

43 Answered Questions

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

58 Answered Questions

[SOLVED] How to create a memory leak in Java?

66 Answered Questions

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

  • 2008-12-12 18:20:57
  • user42155
  • 4090002 View
  • 3527 Score
  • 66 Answer
  • Tags:   java random integer

44 Answered Questions

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

59 Answered Questions

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

57 Answered Questions

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

15 Answered Questions

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

14 Answered Questions

[SOLVED] Java string to date conversion

19 Answered Questions

[SOLVED] Converting array to list in Java

Sponsored Content