I am making an ATM machine and trying to get my accounts from a .csv file to an ArrayList and am having all sorts of issues. Can I get help? It is giving me problems on line 52 of the class where I read and put the items into Arraylist.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bank_atm;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Xaver
 */
public class BankAccount {
    private int accountNum;
    private String name;
    private double balance;
    private int pin;
    static ArrayList<BankAccount> arl = new ArrayList<BankAccount>();
    
    public BankAccount(int accountNum, String name, double balance, int pin)
    {
        this.accountNum = accountNum;
        this.name = name;
        this.balance = balance;
        this.pin = pin;
    }

    public BankAccount() {
        int tempNum, tempPin;
        String line, tempName; 
        double tempBalance; 
        String [] temp;
        FileReader fr;
        try 
        {
            fr = new FileReader("Bank.csv");
            Scanner s = new Scanner(fr);
            tempName =  s.nextLine();
            
            while (s.hasNext())
            {
                line = s.nextLine();
                temp = line.split(",");
                
                tempNum = Integer.parseInt(temp[0]);
                tempName = temp[1];
                tempBalance = Double.parseDouble(temp[2]);
                tempPin = Integer.parseInt(temp[3]);
            
                
                    arl.add(new BankAccount(tempNum, tempName, tempBalance, tempPin));
                
            }
            
            
        } 
        catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(null, "File not found.");
            Logger.getLogger(BankAccount.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }

    public void setArl(ArrayList<BankAccount> arl)
    {
        this.arl = arl;
    }
    
    
    
    
    
    public int getAccountNum() {
        return accountNum;
    }

    public static ArrayList<BankAccount> getArl() {
        return arl;
    }

    public double getBalance() {
        return balance;
    }

    public String getName() {
        return name;
    }

    public int getPin() {
        return pin;
    }
    
    
    
    
    
    
}
@Action
    public void selectDelete() {
        if(jRadioButton1.isSelected())
            jTextField2.setEnabled(false);
            jTextField3.setEnabled(true);
            jTextField4.setEnabled(false);
            jTextField5.setEnabled(false);
            jButton13.setEnabled(true);
    }

    @Action
    public void selectAdd() {
        if(jRadioButton2.isSelected())
            jTextField2.setEnabled(true);
            jTextField3.setEnabled(true);
            jTextField4.setEnabled(true);
            jTextField5.setEnabled(true);
            jButton13.setEnabled(true);
    }

    @Action
    public void addOrDel() {
        BankAccount b = new BankAccount();
        if(jRadioButton1.isSelected())
        {
            
            ArrayList<BankAccount> arl = BankAccount.getArl();
            ArrayList<BankAccount> tempArl = new ArrayList<BankAccount>();
            for (BankAccount ba: arl)
            {
                if (ba.getAccountNum() == Integer.getInteger(jTextField3.getText().toString()))
                {
                    JOptionPane.showMessageDialog(mainPanel, "Account was deleted.");
                }
                else
                {
                    JOptionPane.showMessageDialog(mainPanel, "Process Complete. If no prior message was received \n then Account wasn't deleted.");
                    tempArl.add(new BankAccount(ba.getAccountNum(), ba.getName(), ba.getBalance(),ba.getPin()));
                }
                
            }
            b.setArl(tempArl);
        }
        else if (jRadioButton2.isSelected())
        {
            ArrayList<BankAccount> arl = BankAccount.getArl();
            
        }
        else
            JOptionPane.showMessageDialog(mainPanel, "There was an Error, try again.");
    }

Edited 5 Years Ago by Nandomo: n/a

Integer.getInteger(tempNum) returns an Integer object, but your bsnk account constructor requires an int value. Have a look at Integer.parseInt(...)
(Etc)

This question has already been answered. Start a new discussion instead.