// BAD constructor protected di(int paramInt) { this.aS = (256 + paramInt); if (c[(256 + paramInt)] != null) { // Shouldn't do all those tests just to throw the problem out the window and write a debug line System.out.println("CONFLICT @ " + paramInt); } // "this" is not necessarily initialized (Classes that extend "di" might not call super(int) last, for example) c[(256 + paramInt)] = this; } // GOOD constructor // Scope changed to "private" private di(int paramInt) { this.aS = (256 + paramInt); // Conflict tests removed--we could do an assert or handle the error properly, but probably unecessary // Bad use of "this" removed } // Added di.create(int) wrapper with the scope of the constructor it is replacing protected static di create(int index) { di item = new di(index); // Do our static housekeeping AFTER the new object is fully initialized c[256 + index] = item; // Return the item to emulate a basic "new di" instantiation return item; }