Cannot find local variable 'ac'
<p>Below my code but it is not working - refer to <a href="https://i.stack.imgur.com/WYTXT.png" rel="nofollow">this screenshot of the error during debugging</a>,</p>

<blockquote>
  <p>Cannot find local variable 'ac'</p>
</blockquote>

<pre><code>    AccountManager am = AccountManager.get(this);
    Account[] accounts = am.getAccounts();
    for (final Account ac : accounts)
    {
        String acname = ac.name;
        System.out.println("Accounts : " + acname);

    }
</code></pre>