Vector.size() in Java -
how vector.size()
work exactly, returning aleready known array.length
or makes calculations every time?
my point is.. better have variable store vector's size when need use in loop example :
int vectorlength = myvector.size(); (int = 0; < vectorlength; i++) { //... }
or can use directly vector.size()
? better in terms of memory , cpu time used?
you can @ actual codes how implements it:
308 * @return number of components in vector 309 */ 310 public synchronized int size() { 311 return elementcount; 312 }
the link here: http://www.docjar.com/html/api/java/util/vector.java.html
it int value getter.
Comments
Post a Comment