创建等同行动 在Java中,从C#

问题描述 投票:0回答:1

我有在C#中,看起来像代码:

 Action<Guid, QueryResult> onData = (guid, data) =>
 {
      total += data.NumberOfRows;
      Console.WriteLine("Guid: {0} Number of rows: {1}", guid, data.NumberOfRows);
 };

我想在Java中复制这一点,但是我不能确定相应的Java的,以取代操作码

谁能指教?

java action
1个回答
0
投票

这里是:

 BiConsumer<String, Integer> resultBiConsumer = new BiConsumer<Guid, QueryResult>() {
     @Override
     public void accept(Guid s, QueryResult data) {
         total += data.numberOfRows;
         System.out.printf("Guid: %s  Number of rows: %d%n", s, data.numberOfRows);
     }
 };
© www.soinside.com 2019 - 2024. All rights reserved.