I am just trying to find how much time it takes for the loop execution for the following scenarios

By initalizing the vector with 1000. The output i got is some 16 millisecs. The output is not consistent and i also tried to check, which iteration is taking the time. For the first execution, the 7th iteration takes 2 ms and then 61 takes some millisecs and so on. Even this is not consistent. I just want to know why the output is not consistent and also why it is taking a time for a particular iteration. It is because of memory allocation each time or arraycopying or for garbage collection?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus

Yes, there is no chance whatsoever that your code will yield any useful performance information.

The System.currentTimeMillis() has a maximum resolution of only milliseconds. A computer can do a heck of a lot in a millisecond: much more than just add an item to a Vector! But it's worse than that, because some implementations of Java don't actually update the clock every millisecond; they jump every few milliseconds.

As already mentioned System.out.println() will always take significant time and can take a long time, if there is scrolling to do, for instance. Never do input/output inside a computational loop that you're trying to time.

And again as already mentioned, ordinary computers running ordinary Java just are nothing like as predictable as you imagine. Java code takes different amounts of time to run the same statements depending on many things, including HotSpot compilation.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.