Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

An enclosing instance that contains...

807606Feb 20 2007 — edited Feb 21 2007
What's wrong?

Type:
public abstract class Type {
	public class Sub1 extends Type {
		public Sub1() {
			super();
			System.out.println("... one done!");
		}
	}
	
	public class Sub2 extends Type {
		public Sub2() {
			super();
			System.out.println("... two done!");
		}
	}
	
	public class Sub3 extends Type {
		public Sub3() {
			super();
			System.out.println("... three done!");
		}
	}
	
	private static int value = 0;
	
	protected Type() {
		value++;
		System.out.print("Type " + value);
	}
}
TestType:
public class TestType {
	public static void main(String[] args) {
		System.out.println("Types creation:");
		Type type1 = new Type.Sub1();
		Type type2 = new Type.Sub2();
		Type type3 = new Type.Sub3();
	}
}
The compiler gives me the error of subject: An enclosing instance that contains Type.Sub1 is required...

but I don't understand where the problem is o_O
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2007
Added on Feb 20 2007
3 comments
2,268 views