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.
empindex.contains("1") - tells you whether "1" is in the vector
empindex.indexOf("1") - tells you what position it's in in the vector
This is silly code. A simple indexOf("1") would give you the same information without the invitation for disaster that comes with the magic number 99. What if the position of "1" really was position 99? This method would seem to tell you it was not found, which is wrong.
See the JavaDoc for Vector, read up on contains() and indexOf(). See if you can replace the body of this horror one line of code.
See the JavaDoc for the Collection interface and some of the classes in the "see also" section. See if you can avoid ever using Vector again.
Keep reading code and asking questions! Learning is fun! [ November 03, 2004: Message edited by: Stan James ]
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi