it was different post by mistake I mixed it in hashCode() method
Joined: Oct 13, 2005
If it was an interview question, why didn’t you say so? Those questions are completely unrelated to real life. You can’t say what the capacity of a Vector it, unless you have seen all its method calls. Even then you might not know it. You are better off going on about not knowing implementation details, and how you don’t worry about capacity because you know it changes to accommodate whatever you put in it. Also say you usually use ArrayList, which might have a different mechanism for increasing capacity. Mentioning the ensureCapacity method and how it speeds up adding would be a good move.