Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Need Help with Method Reference for System.out.println(k, v)

 
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I was trying to learn Lambdas and Method Reference.

The following code with BiConsumer Interface that create a List and copy it's content into Map's value... It works vary well when I run with the Lambda syntax (if I run with the commented Lambda stetment). But when I try with the Method Reference it give me a compile time error Incompatible types: invalid method reference for System.out::println. What is wrong here? Does it possible with Method Reference?



Thanks,
Regards...
Suketu Patel
 
Saloon Keeper
Posts: 12163
258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you can't do this with a method reference, because there is no println() method that has two parameters. A BiConsumer is only compatible with methods that take two parameters.
 
Suketu Patel
Greenhorn
Posts: 23
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephen... I missed that.😩😩😩
 
    Bookmark Topic Watch Topic
  • New Topic