|
|
|
|
|
by Alupis
4090 days ago
|
|
> The author doesn't even notice that the second argument of && is redundant and keeps it in the "refactored" version as well.. That's false. A list object may be initialized but be empty (making it's length zero). Or it may not be initialized (making it null). Both conditions may happen independently of one another. He checks for the null first so that checking the length does not throw a NPE. > The if-statement is a good summary of what is wrong with Java. Frankly, I see nothing wrong here. |
|
I know an even lower level language (C++, C) that doesn't have the problem of things which make no sense to be NULL (list elements). The problem is that Java did away completely with value types and made everything pointer only. That has been recognized by later languages (C#) and fixed.
The whole code consists of problems: the first is the language, the second is the programmer, the third is the missing for-each construct.