I often see java SourceCode where a null as value for a method or constructor is not allowed. A Typical implementation of this looks like
public void someMethod(Object someObject){
if(someObject == null) throw new NullPointerException()
someObject.aMethodCall()
}
I see no sense for myself in that at all, because if I attempt to call a Method on a nullPointer the NullPointerException is thrown anyways. I would see a sense if this method would throw an IllegalArgumentException or some other custom-made exception. Can someone clearify , why this check seems to makes sense (as I see it very often I’m assuming, that there has to be sense behind that), or why it’s complete nonsense
The code you posted makes absolutely no sense at all. It looks like a strong case of cargo cult programming. Most likely, somebody implemented a useful test to check for pre-conditions once and somebody else adapted the test to look like this.