Error when reading instances
<p>I have been working on this sort of ATM (With a maximum of 50 customers), where I read a .txt file, and then create multiple instances, store them in an array, so that other classes can call on them.
When I read the file, only the last customer's information are inputted correctly - I can't ever get the first few customers to have their output correct.</p>

<p>There are multiple methods for each 'Set', just in case the field says 'none', so that I can leave it as a </p>

<pre><code>   Double.NaN or null, for example.
</code></pre>

<p>I have researched on a few websites, and there wasn't very much on storing instances in arrays, although on one website, it said that I should declare it just like a normal array.</p>

<pre><code>  private static String firstname = "";
  private static String lastname = "";
  private static int sin = 0;
  private static int year = 0;
  private static int month = 0;
  private static int day = 0;
  private static double sbalance = 0.0;
  private static double cbalance = 0.0;
  private static double cardbal = 0.0;
  private static boolean confirm = false;

  public int customernumber;
  public static customer [] customerarray = new customer [50];


  public static void readfile(){
     String sb = "";
     String cb = "";
     String ca = "";

     int counter = 0;
     String thisLine;


     try {
        BufferedReader br = new BufferedReader(new FileReader("bankinfo.txt"));
        while ((thisLine = br.readLine()) != null) {
           customerarray[counter].setLastName(thisLine);
           System.out.print (customerarray[counter].getLastName());
           customerarray[counter].setFirstName(br.readLine());
           System.out.print (customerarray[counter].getFirstName());
           customerarray[counter].setSin(Integer.parseInt(br.readLine()));
           System.out.print (customerarray[counter].getSin());
           customerarray[counter].setYear(Integer.parseInt(br.readLine()));
           System.out.print (customerarray[counter].getYear());
           customerarray[counter].setMonth(Integer.parseInt(br.readLine()));
           System.out.print (customerarray[counter].getMonth());
           customerarray[counter].setDay(Integer.parseInt(br.readLine()));
           System.out.print (customerarray[counter].getDay());
           sb = br.readLine();
           if (sb.equals("none")){
              customerarray[counter].setSBalance("none") ;
              System.out.print (customerarray[counter].getSBalance());
           }
           else {
              customerarray[counter].setSBalance(Double.parseDouble(sb));
              System.out.print (customerarray[counter].getSBalance());
           }
           cb = br.readLine();

           if (cb.equals ("none")){
              customerarray[counter].setCBalance ("none");
           }
           else if (cb != "none"){
              customerarray[counter].setCBalance(Double.parseDouble(cb));
           }
           else{
              System.out.print ("error CBalance");
           }

           ca = br.readLine();
           if (ca.equals("none")){
              customerarray[counter].setSBalance("none") ;
           }
           else {
              customerarray[counter].setCardbal(Double.parseDouble(ca));
           }

           counter = counter + 1;

        }  
        br.close();
     }

        catch (IOException e) {
           System.err.println("Error: " + e);
        }

  }
</code></pre>

<p>The text file is fairly simple- it is composed of 9 fields for each customer.
If they do not have a certain account, it is listed as 'none', and when the reader reads them, it uses a variant method with a String input, and sets the double = Double.NaN();</p>

<p>The following is an example of the text file.
Each customer has 9 fields.</p>

<pre><code>Tam
Christian
984635684
1996
6
12
none
10233.52
none
Yang
Wesley
324917400
1996
8
1
3233.36
none
none
Lin
Sophia
1984
1985
5
6
912.12
58.96
95.63
</code></pre>
