This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by Chinmay Bajikar: What is the difference between how Vector.contains() searches in the vector and how Vector.indexOff() searches in the vector? Also which one is efficient??
From the source code of Vector:
You can see that Vector's contains() calls its two-argument indexOf() method. (And the single-argument version of indexOf() also calls the two-argument indexOf().) So they search the same way! Can't imagine that the extra method calls of contains() or single-argument indexOf() have any (measurable) performance impact. I'd base my decision between the two on which return type I need: contains() returns a boolean and indexOf() returns an integer index.