I have the following code in the mClass constructor:
public mClass(Context ctx) {
super();
this.ctx = ctx;
}
The context can't be null because its necesary for the object operation. So if I allow the creation of an new mClass(null) it will break later.
I'd like to crash when the object is create because is when the incorrect situation is happening. Whats the standard way of doing this?
For example making
public mClass(Context ctx) {
super();
if(ctx==null) throw new Exception ("....");
this.ctx = ctx;
}
forces to declare the method as exception thrower and I dont wan't to do this because passing a null value is not usual