Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
JSP - A mailing list about Java Server Pages specification and reference
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Subject: Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Subject: Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Looping...

Looping...

2006-11-09       - By Emmanuel Eze

 Back
Reply:     1     2  

I do not think that there's any problem with your approach.  However,
for code neatness, I would have written it as:

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



Ne'Bahn wrote:

> 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) and include in the
> body
> of the message "signoff J2EE-INTEREST".  For general help, send email to
> listserv@(protected) and include in the body of the message "help".
>


--
*Emmanuel Eze*
Home Page <http://emma.ukrosoft.com>: http://emma.ukrosoft.com
/With the right attitude - we can achieve the seemingly impossible!/

===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <meta content="text/html;charset=ISO-8859 (See http://ISO-8859.ora-code.com)-1" http-equiv="Content-Type">
 <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I do not think that there's any problem with your approach.&nbsp; However,
for code neatness, I would have written it as:<br>
<br>
public boolean find(double searchKey) {
<br>
&nbsp;boolean flag;<br>
&nbsp;for (int i = 0; i &lt; items; i++)
{<br>
&nbsp;&nbsp;&nbsp; &nbsp; if (values[i] == searchKey) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; flag = true;
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; break;<br>
&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp; }<br>
&nbsp;&nbsp; return flag;
<br>
}
<br>
<br>
<br>
<br>
Ne'Bahn wrote:
<blockquote cite="mid000e01c70289$400ce330$66d3dcc9@(protected)"
type="cite">Hi list:
 <br>
 <br>
What are the consecuences of breaking a loop in this manner:
 <br>
 <br>
// items - the number of items on the array
 <br>
// values - the array itself
 <br>
 <br>
public boolean find(double searchKey) {
 <br>
&nbsp;for (int i = 0; i &lt; items; i++)
 <br>
&nbsp; if (values[i] == searchKey)
 <br>
&nbsp;&nbsp; return true;
 <br>
&nbsp;return false;
 <br>
}
 <br>
 <br>
AFAIK when an instance leave a method all variables "dissapear" (stack
 <br>
flushes, take some air, if they are objects the garbage collector
prepares
 <br>
for..). The fact is that I don't like to use the "break" keyword so I
want
 <br>
to know if this way is the same that "break, then return".
 <br>
 <br>
Thanks in advance.
 <br>
 <br>
===========================================================================
 <br>
To unsubscribe, send email to <a class="moz-txt-link-abbreviated" href="mailto
:listserv@(protected)">listserv@(protected)</a> and include in the
body
 <br>
of the message "signoff J2EE-INTEREST".&nbsp; For general help, send email
to
 <br>
<a class="moz-txt-link-abbreviated" href="mailto:listserv@(protected)"
>listserv@(protected)</a> and include in the body of the message "help".
 <br>
 <br>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<b>Emmanuel Eze</b><br>
<a title="Emmanuel Eze" href="http://emma.ukrosoft.com">Home Page</a>:
<a class="moz-txt-link-freetext" href="http://emma.ukrosoft.com">http://emma
.ukrosoft.com</a><br>
<font color="#006600"><i>With the right attitude - we can
achieve the seemingly impossible!</i></font>
</div>
</body>
</html>
===========================================================================
To unsubscribe, send email to listserv@(protected) and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@(protected) and include in the body of the message "help".
<p>

©2008 junlu.com - Jax Systems, LLC, U.S.A.