Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Sybex Practice Tests 11, chapter 6, question 57, page 207

 
Ranch Hand
Posts: 73
Mac IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good afternoon,

The code in the question is:



but this code doesn't compile, because line 3 has to be;

var map = s.collect(Collectors.toMap(String::length, k -> k, merge));

Or do I have to assume that the necessary static import is available?

Thanks in advance.
 
Ranch Foreman
Posts: 343
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have that specific book, and the authors may drop by soon to make a more authoritative statement.

One nice hint they often provide, is that if numbering the lines, if they mean it to be read as a complete piece of code, they will start the numbering from 1, or with a package statement, or show at least one import.

If they mean it to just be a fragment, with whatever necessary stuff up above, they will start numbering the lines from 3 or 5 or or something like that.

Do they number the lines or show anything else above the "var s" line?
 
Space pants. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic