Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Sybex 819, Chapter 14, Table 14.7

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Table has method definition written in short form as



which appears to be a bit confusing as BiConsumer seems to look like a method (rather than a functional interface) with two parameters, especially if needed to be consistent with the other table entries.

Perhaps better written as

 
Saloon Keeper
Posts: 3848
42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have the book, but based on your input I agree.

One more thing: to avoid confusing, please do not use K(ey) / V(alue) type parameters for BiConsumer.

Consumer and BiConsumer may accept some parameter(s), so, a plain parameter usually denoted T(ype), and if you need a second, then used the next letter in the alphabet U, then V, and so on...

These declarations are better IMHO

P.S. this is just a convention, not mandatory, simply to avoid confusion.

<K,V> things are applicable to Map, HashMap, etc..
 
Taiwo Ajayi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your comments. The table was describing map methods, hence the conventional K, V being used.
 
author & internet detective
Posts: 41763
885
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yech. In addition to being confusing, it is wrong. forEach() and merge() have that problem in the Java 17 book too. (table 9.6 there). I've added this to the errata of the Java 11 and 17 books and credited you
 
If you send is by car it's a shipment, but if by ship it's cargo. This tiny ad told me:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic