Void is also a dummy class.
Void also refers generically to the various flavours of hollow Strings, namely: blank (i.e x.length() != 0 && x.trim().length() == 0, e.g. ), empty (i.e. x.length() == 0, e.g. "") and null (i.e. x == null). One of the most common sources of error in Java programs comes from confusing the three different flavours of void strings. Java code often has a maintenance timebomb ticking in it in the form of inconsistent representation of void strings and objects. It is unwise to just let NullPointerException find your problems for you. The problem may surface many kilometers from the true source of the problem. There will always be one more bug. It is better to decide on your canonical void representation and be fanatically rigid about it.
Which void representation should you use?
There are two plausible canonical representations for void namely null and empty (""). Normally you combine either of them with canthappen. The four ways you might represent void Strings are:
In a similar way you can get into trouble returning null instead of an empty Collection. One convention, used by File.list, is to return an empty array or Collection for no elements, and null to represent the result of an invalid request.
// making IntelliJ @NotNull and @Nullable available to your program import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;The IntelliJ annotations.jar file must be available to javac.exe on the processorpath (usually the classpath) for them to work. You must specify the specific jar, not just the directory.
|
|
available on the web at: |
http://mindprod.com/jgloss/void.html |
optional Replicator mirror
|
J:\mindprod\jgloss\void.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[54.235.20.17] |
|
| Feedback | You are visitor number 80,343. | |