• 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
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 3928
43
  • 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: 41967
911
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
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic