I have a generic static inner class inside a generic non-static class. It gives me errors because E cannot be accessed from a static context:

public class List<E>{

public static class InnerClass<E>{


How do I fix this? Thanks!

Why do you need your inner class to be static?

The inner class simulates a heap... It has an array of Cells (a class nested in the inner class) and gives open Cells to instances of List...

So... when you add something to the List, what happens is the List requests a Cell from the static heap:

public void add(E item){

// get open cell
Cell tmpCell = heap.getCell();



So... the idea is that lots of Lists will be requesting Cells from the heap.

The program is assignment that I am working on, that is why I have an inner class that simulates a heap.

You didn't show how Cell is declared, but you mentioned that it was a nested inner class. I would guess that you didn't declare it static. It would need to be static if you want to use it in a static context. Non-static inner classes require an instance of the enclosing class.