'Accessing methods of methods of interfaces directly created in Arraylist

I have created an ArrayList named Accounts and then directly created a object in it using add method. Is there a way in which I can access the methods of the object?

public class Main {

    static ArrayList<Object> accounts = new ArrayList<Object>();
    static Scanner sc = new Scanner(System.in);
    static int nextAccNumber = 0;

    static void addAccounts()
    {
        System.out.println("Enter your name");
        String name = sc.next();
        System.out.println("Enter the amount of money you want to deposit");
        int money = sc.nextInt();
        accounts.add(new Accounts(name, money, nextAccNumber));
        System.out.println("New Account created");
        System.out.println("Account number : " + nextAccNumber);
        //There is a variable, Password in Accounts class which automatically is generated the class
        System.out.println("Password : " + accounts.get(nextAccNumber).getPassword); // This doesn't work
        nextAccNumber++;
    }

As you saw, I want to access getPassword method, but by simply doing it by referencing it from the arrayList doesn't work. Is there a way I can make this work?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source