【问题标题】:How to write an Action function with two parameter in java如何在java中编写一个带有两个参数的Action函数
【发布时间】:2016-02-16 06:41:45
【问题描述】:

我有以下用 VB.Net 编写的函数,有没有办法将其转换为 Java。我试过Consumer(),但它只接受一个参数。

Dim setFunc 
As Action(Of String, Object) = Sub(name, val) 
                               Console.WriteLine
                               ("Test Function. Name: {0}, Value: {1}", name, val)

【问题讨论】:

  • 你试过BiConsumer吗?

标签: java vb.net java-8 action consumer


【解决方案1】:

你试过了吗

BiConsumer<String, Object> setFunc = 
      (x, y) -> System.out.println("Test Function. Name : " + x + ", Value " + y);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多