• Post Reply Bookmark Topic Watch Topic
  • New Topic

Equivalent of lamda expression and Collectors in java 1.7  RSS feed

 
swathi bairu
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code in Java 1.8.

How can I convert this to make it to work in Java 1.7?
 
Paweł Baczyński
Bartender
Posts: 1998
42
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code:
1. Takes request.getHeaderNames() (which I believe is of type Enumeration<String>)
2. Converts it to a list.
3. Applies a mapping on each element of the list.
4. Joins them all together in a form {element1, element2, element3}
5. Appends "\n" to the end.

You can oparate on a list using a for loop:
Then apply a conversion:You can oparate on a list using a for loop:
Then add appending everything into a StringBuilder and that would be it.
 
swathi bairu
Ranch Hand
Posts: 85
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paweł Baczyński wrote:
That worked. Thank you :-)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!