Usually when you make a code,
if (someobject != null) {
someobject.doCalc();
}
They're making exceptions in the same way, but they look so dirty to me Is there a way to make it cleaner?
java nullpointerexception
Each developer has a different way of handling exceptions, but if that way looks messy, Why don't we use the assert?
assert someobject != null;
If you do this, when some object is null, an error is caused by the alert statement
But usually, if some object is not supposed to be null, for some processing,
if( someobject == null ){
//someobject processing
}
someobject.somemethod();
I think it would be good to do it like this
© 2024 OneMinuteCode. All rights reserved.