[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: programing styles



I would have to ask are you going to need obj and/or y outside the loop if
so you will have to use 2 else it is a matter of preference.  Another
question unless you need synchronization you will see better performance
from a List.  This is because all method calls to a Vector are synchronized.
If you need to use a Vector an Iterator or Enumerator would be better for
Iterating if using 1.3.  I am not sure if Iterator is in Vector for 1.2

Tim McCauley

-----Original Message-----
From: Gudavalli, Manidhar [mailto:manidhar.gudavalli@eds.com]
Sent: Friday, November 01, 2002 2:34 PM
To: ajug-members@ajug.org
Subject: programing styles





HI

Which  style of coding is best ?

[1]
private void myproc(Vector vect){
for (i=1; i < vect.size() ; i++){

MyObject obj = (MyObject) vect.elementAt(i);
  int y = obj.getY();
}
}

or
[2]
private void myproc(Vector vect){
MyObject obj = null;
int y= 0;

for (i=1; i < vect.size() ; i++){

  obj = (MyObject) vect.elementAt(i);
    y = obj.getY();
}
}