Java 8 – Calling a multi argument method from

  • A+

I've been using the java 8 Streams for a while. I came across a situation where I need to stream through a List and pass each element to a static method along with another argument. Is it possible in java 8?

........ String designation = "Engineer"; List<String> names = new ArrayList<>(); names.add("ABC"); names.add("DEF"); names.add("GHI");; ..........  class MyClass {     public static void createReport(String name, String designation) {        System.out.println(name+"/t"+designation);     } } 

How can I pass the designation String via stream().map()?


Use a lambda expression: -> MyClass.createReport(name,designation))... 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: