The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Use contains ( ) method

Posted by Kishori Sharan on February 18, 2001 at 3:42 PM

Suppose you are going to add an element e1 in a vector v1 and before adding you want to know if e1 already exists in the vector v1 then you can use contains() method of vector as

if ( v1.contains ( e1 ) ) {
// e1 already exists in v1
}
the contains method returns true if e1 is already there in v1 else it returns false.



Replies:
  • Vector Jas. April 08, 2001 at 11:08 PM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us