Get value inside from a objects method in arraylist in Java?
<p>I'm trying to select and get values from customer objects. What I want to do is to enter a personal number like "702312" and search after the customer objects that has a data member personal number that are equal to "702312". And when I found it I want to get the rest of the values or change it's content. This is some code that creates the customer objects from the class Customer and then it's stored in a arraylist.</p>

<pre><code>// create a new customer object and send personal number, name and account number to constructor
Customer customer = new Customer(personalNumber, name, newAccountNumber);

// create an arraylist to store customer objects
ArrayList&lt;Customer&gt; customerList = new ArrayList&lt;Customer&gt;();

// add the new customer object to arraylist that holds all customer objects
customerList.add(customer);
</code></pre>

<p>I have tried to reach the values like this, but it's not working, so I'm looking for some help?</p>

<pre><code> // search for customer
 for (Customer customer : customerList) {
if(customer.getAccountOwnerPersonalNumber() == "702312"){
    System.out.println("OK!!!");
    }
 }
</code></pre>

<p>And instead of:</p>

<pre><code> if(customer.getAccountOwnerPersonalNumber() == "702312")...
</code></pre>

<p>I have tried this:</p>

<pre><code> if(customer.personalNumber == "702312")...
</code></pre>

<p>Finally I have also tested it like this:</p>

<pre><code>for(int i=0;i&lt;customerList.size();i++){
    if(customerList.get(i).getAccountOwnerName() == "702312");
    System.out.println("OK");
    break;
}
</code></pre>

<p>I'm not sure if I'm doing right!? Help is preciated! Thanks!</p>
