I have the following code:
class Hello {
class Thing {
public int size;
Thing() {
size = 0;
}
}
public static void main(String[] args) {
Thing thing1 = new Thing();
System.out.println("Hello, World!");
}
}
I know Thing
does nothing, but my Hello, World program compiles just fine without it. It's only my defined classes that are failing on me.
And it refuses to compile. I get No enclosing instance of type Hello is accessible."
at the line that creates a new Thing. I'm guessing either:
- I have system level problems (either in DrJava or my Java install) or
- I have some basic misunderstanding of how to construct a working program in java.
Any ideas?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…