Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

Looping...

Ne'Bahn

2006-11-07

Replies:

Hi list:

What are the consecuences of breaking a loop in this manner:

// items - the number of items on the array
// values - the array itself

public boolean find(double searchKey) {
for (int i = 0; i < items; i++)
 if (values[i] == searchKey)
  return true;
return false;
}

AFAIK when an instance leave a method all variables "dissapear" (stack
flushes, take some air, if they are objects the garbage collector prepares
for..). The fact is that I don't like to use the "break" keyword so I want
to know if this way is the same that "break, then return".

Thanks in advance.

===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".
©2008 junlu.com - Jax Systems, LLC, U.S.A.