Java Guava | Longs.contains() method with Examples
The Longs.contains() method of Guava’s Longs Class is used to check if a value i.e. target is present in the array or not. This target value and the array are taken as parameters to this method. And this method returns a boolean value that states whether the target value is
public static boolean contains(long array, long target)
Parameters: This method accepts two parameters:
- array: which is the array of values in which the target value is to be searched
- target: which is the long value to be checked for presence.
Return Value: The method returns True if for some value of i, the value present at ith index is equal to the target, else returns False.
Exceptions: The method doesn’t throw any exception.
Target is present in the array
Target is not present in the array