Error with return in Java?
<p>I get an error in the code from this part of my code:</p>

<pre><code>public boolean findCustomer(String inPersonalNumber){

    // check if personal number already exist
    for (int i=0; i&lt;customerList.size();i++) {
        if(customerList.get(i).getCustomerPersonalNumber().equals(inPersonalNumber)){
            return true;
        }
    }
    return true;    
}
</code></pre>

<p>When I remove the first return true and instead to the last return true, it don't get the error in my eclipse code, but why can't I have the first place and would this be the same? Thanks!</p>

<p>EDIT: The error message from eclipse say: This method must return a result of type boolean. I'm confused because isn't that what I have done?!</p>

<p>Yes, a break must be in the code</p>

<p>Can I write the method in some other way?</p>

<p>EDIT NUMBER 2<br>
Why isn't this code working?</p>

<pre><code>public boolean findCustomer(String inPersonalNumber){

// check if personal number already exist
for (int i=0; i&lt;customerList.size();i++) {
    if(customerList.get(i).getCustomerPersonalNumber().equals(inPersonalNumber)){
            return true;
        }
        else {
            return false;
        }
    }
}
</code></pre>

<p>This method returns a boolean value so I don't understand why I get an error!? The code looks right to me?</p>
