title: Accessing methods of methods of interfaces directly created in Arraylist
body: <p>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?</p>
  <pre class="lang-java prettyprint-override"><code>public class Main {
  
      static ArrayList&lt;Object&gt; accounts = new ArrayList&lt;Object&gt;();
      static Scanner sc = new Scanner(System.in);
      static int nextAccNumber = 0;
  
      static void addAccounts()
      {
          System.out.println(&quot;Enter your name&quot;);
          String name = sc.next();
          System.out.println(&quot;Enter the amount of money you want to deposit&quot;);
          int money = sc.nextInt();
          accounts.add(new Accounts(name, money, nextAccNumber));
          System.out.println(&quot;New Account created&quot;);
          System.out.println(&quot;Account number : &quot; + nextAccNumber);
          //There is a variable, Password in Accounts class which automatically is generated the class
          System.out.println(&quot;Password : &quot; + accounts.get(nextAccNumber).getPassword); // This doesn't work
          nextAccNumber++;
      }
  </code></pre>
  <p>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?</p>