Predicate isEqual example

Description

Predicate isEqual returns a predicate that tests if two arguments are equal according to Objects.equals(Object, Object).

Syntax

isEqual has the following syntax.


static <T> Predicate<T> isEqual(Object targetRef)

Example

The following example shows how to use isEqual.


import java.util.function.Predicate;
/*from   www.  j  a  v  a  2s. c  o  m*/
public class Main {

  public static void main(String[] args) {
    Predicate<String> i  = Predicate.isEqual("asdf");
    
    System.out.println(i.test("java2s.com "));
  }
}

The code above generates the following result.