the constructor of class java.util.logging.logrecord(level level, string msg)
explains explicitly in code in first line invokes random line of code check variable level
not null.
// make sure level isn't null, calling random method.
are there hidden explanations this?
here screenshot of constructor can check directly ide.
it example of implicit null check.
even though comment says 'random method' getclass() chosen because:
- it shorter writing explicit if check null , throwing new nullpointerexception. on other hand there long comment explaining short code.
- it free of side effects.
- it declared final , can't overridden subclass.
- the code written prior java.util.objects.requirenonnull.
Comments
Post a Comment