This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Do you know what the "val == null" flow control line mean? It is not related to the iteration of the list, what kind of value is "E val" suppose to be?
Studying for the OCP that's why i need to know all these details.
Nick Widelec wrote:Do you know what the "val == null" flow control line mean? It is not related to the iteration of the list, what kind of value is "E val" suppose to be?
Well, in the particular case you show, it's trying to find the element to replace. There's nothing in the rules that says a List can't contain null elements, and using equals() to check whether an object equals null doesn't make sense, because, in order to call the method, the object can't be null (and besides, you'll get a NullPointerException).
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here