import java.util.*;
    class Customers
    {

        private String name;
        private int accountno;
        private String status;
        private String type;
        private int currbal;
        private String Login;
        private int Pin;

        public Customers()
        {

            this.name   = " ";
            this.accountno = accountno;
            this.currbal = currbal; 
        }
        public Customers( String name1, int A, int Bal)
        {
            name = name1;
            accountno = A;
            currbal = Bal;      
        }
        public Customers ( String name1,int accountno1, String status1, String type1, int curr, String Login1, int Pin1)
        {   
            name = name1;
            accountno = accountno1;
            status = status1;
            type = type1;
            currbal = curr;
            Login = Login1;
            Pin = Pin1;
        }
        public String getHolderName()
        {
            return name;
        }

    }

    class ATMmain
    {
        public static void main( String [] args)
        {
            int count = 1;

            Customers [] Carray = new Customers [100];
            //Customers [] C1 = new Customers[1];
            //Customers [] C2 = new Customers[1];
            System.out.println(createNewAccount(count, Carray));
            System.out.println(createNewAccount(count, Carray));
        }

        public static int createNewAccount( int count, Customers [] Carray)
        {
            //Customers [] Carray = new Customers[10];
            System.out.println("Enter account information");
            Scanner S = new Scanner (System.in); 
            System.out.println("Login:");
            String log = S.next();
            System.out.println("Pin Code:");
            int Pin = S.nextInt();
            System.out.println("Holder's name: ");
            String holderN = S.next();
            System.out.println("Type:" );
            String type = S.next();
            if (!type.equals("Savings") && !type.equals("Current"))
            {
                System.out.println("error type! please Re-enter");
                System.out.println("Type:" );
                type = S.next();
            }
            System.out.println("Starting Balance:");
            int SBal = S.nextInt();
            System.out.println("Status:");
            String Stat = S.next();
            Customers ACC = new Customers(holderN, count,Stat, type,SBal,log, Pin );
            Carray[count] = ACC;

            System.out.println("Account Successfully created!");
            System.out.println("account number is" +count);
            count++;
            return count; 

        }
        }

        /*public void DeleteExistingAcc(int count, Customers [] Carray )
        {
            System.out.println ("Enter Account Number: ");
            Scanner S = new Scanner(System.in);
            int acc = S.nextInt();

            System.out.print   ln("Are you sure you want to delete this Account:" +acc);
            Carray[acc].getHolderName();

        }
        */

`Inline Code Example Here`

What is your question, exactly?

You can ask the user if he wants to insert the new instance in the end, or at a position. Then you can copy the last instance to it's next position (right shifting). Similarly, right shift instances from the last to the position in question. Then, overwrite the instance in the current position with the new instance. That's it!

Create an arrayList that has input type your person object. When a new object has been created, simply add it in the arrayList

ArrayList instead of array because, in an array you have to specify the size of the array upon declaration, of course you could copy and move it to a bigger one if it gets filled but it will be too complicated for a simple project so I'd suggest use Arraylist, for more details on it Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.