Why do only static inner classes in Java have static members?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1953530/why-does-java-prohibit-static-fields-in-inner-classes">Why does Java prohibit static fields in inner classes?</a>  </p>
</blockquote>



<p>Let's look at the following code snippet in Java. It just sums up two numbers within the <code>Inner</code> class declared inside the <code>Outer</code> class and works just fine as expected.</p>

<pre><code>package staticfields;

final class Outer
{
    final public static class Inner
    {
        private static int x;
        private static int y;

        public Inner(int x, int y)
        {
            Inner.x=x;
            Inner.y=y;
        }

        public void sum()
        {
            System.out.println(x+y);
        }
    }
}

final public class Main
{
    public static void main(String[] args)
    {
        new Outer.Inner(5, 10).sum();
    }
}
</code></pre>

<hr>

<p>When I attempt to remove the static keyword from the <code>Inner</code> class, it issues a compile-time error indicating that <strong>inner classes can not have static declarations</strong> means that the the static fields (x and y) declared within the Inner class don't work, if it is made non-static.</p>

<hr>

<p>Why do only static inner classes in Java have static members and non-static inner classes don't?</p>
