Is autoboxing possible for the classes I create?
Is there any way to use autoboxing for the classes I create? For example, I have this subclass of Number . public class UnsignedInteger extends Number { int n; public UnsignedInteger(int n) { if(n >= 0) this.n = n; else throw new IllegalArgumentException("Only positive integers are supported"); } } Now, UnsignedInteger i = new UnsignedInteger(88); works perfectly fine, but is there any way to make this compile : UnsignedInteger i = 88; ? It won't for me. Thanks in advance! rgettman In short, no. There's no way to get that to compile. Java only defines a limited set of pre-defined boxing