title: IllegalAccessException on using reflection
body: <p>I was trying to learn reflection and I came across this IllegalAccessException. Please see the following code:</p>
  
  <pre><code>public class ReflectionTest
  {
        public static void main(String[] args)
        {
             Set&lt;String&gt; myStr = new HashSet&lt;String&gt;();
             myStr.add("obj1");
             Iterator itr = myStr.iterator();
             Method mtd = itr.getClass().getMethod("hasNext");
             System.out.println(m.invoke(it));
        }
  } 
  </code></pre>
  
  <p>When I tried to run this program, I got the following: </p>
  
  <pre><code>Exception in thread "main" IllegalAccessException
  </code></pre>
  
  <p>I don't understand what's going on. Any ideas? Thanks in advance.</p>