[H-GEN] Which is better?
David Seikel
won_fang at yahoo.com.au
Sat Apr 24 10:22:05 EDT 2004
On Sat, 24 Apr 2004 21:59:49 +1000
Benjamin <benjamincarlyle at optusnet.com.au> wrote:
> On Sat, 24 Apr 2004 06:12 pm, Harry Phillips wrote:
>
> > I have a question about coding technique. I will give two examples
> > and would like to know if anyone knows which is more effcient or if
> > they are the same.
> > First code:
> > int arrayLen = myArray.length;
> > for (int i = 0; i < arrayLen; i++)
> > ...
> > Second one:
> > for (int i = 0; i < myArray.length; i++)
> > ...
>
> Ok, this is me holding up the C++ flag:
>
> for (vector<foo>::const_iterator it=bar.begin(); it!=bar.end(); ++it)
> {
> ...
> }
>
> :)
> Can't you do something like that in Java?
Java has it's collections framework, which allows something like that.
for (Enumeration commands = servletToDo.elements(); commands.hasMoreElements();)
{
String command = (String) commands.nextElement();
...
}
An example from my own code (but word wrapped by my email client).
If Harry is on the DSIG list, I suggest we take any further discussion on this thread there.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20040425/173346b6/attachment.sig>
More information about the General
mailing list