I’m using a static analyzer in Eclipse to examine my code. One class, foo, has an inner class, bar. I am getting the following error:
JAVA0043 Inner class 'bar' does not use outer class 'foo'
Why is this an error? As long as the outer class uses the inner class isn’t that sufficient to make this information hiding useful and correct?
The inner class is not static.
If the inner class can only ever be used by the outer class, yet the inner class needs no reference to the outer class, then you can make it
private static.If the inner class is known to someone other than the outer class, then it might as well be a top-level class in its own right.