Home » Java Vector contains() Method with Examples

Java Vector contains() Method with Examples

by Online Tutorials Library

Java Vector contains() Method

The contains() method of Java Vector class is used to check the vector which is in use contains the specified element or not. It returns true if this vector contains the specified element, otherwise returns false.

Syntax:

Following is the declaration of contains() method:

Parameter:

Parameter Description Required/Optional
o It is the element whose presence in this vector will be tested. Required

Returns:

The contains() method returns true if this vector contains the specified element, otherwise returns false.

Exceptions:

NA

Compatibility Version:

Java 1.2 and above

Example 1:

Test it Now

Output:

Java is present at the index 1  

Example 2:

Test it Now

Output:

Existence: true  

Next TopicJava Vector

You may also like