How to check if element exists using a lambda expression?

前端 未结 3 959
失恋的感觉
失恋的感觉 2020-12-07 15:26

Specifically, I have TabPane, and I would like to know if there is element with specific ID in it.

So, I would like to do this with lambda expression in Java:

<
3条回答
  •  时光说笑
    2020-12-07 15:51

    Try to use anyMatch of Lambda Expression. It is much better approach.

     boolean idExists = tabPane.getTabs().stream()
                .anyMatch(t -> t.getId().equals(idToCheck));
    

提交回复
热议问题