R
Robin Wenger
I have the following code:
public void myiteration(List <MyObject> mylist) {
if (mylist != null) {
for ( MyObject mo : mylist) {
... }
}
As you can see I have to check at first whether the passed list is null or not.
If the is null and have no "if" check on the null value then the prog would crash at the "for" loop.
Ok, it works as shown before.
However I would appreciate to be able to treat an null value as an empty list.
I want to omit the leading, wrapping "if" check.
Is this possible somehow?
Maybe with a workaround like:
for (MyObject mo : mylist; (mylist = NOT(null)))
Robin
public void myiteration(List <MyObject> mylist) {
if (mylist != null) {
for ( MyObject mo : mylist) {
... }
}
As you can see I have to check at first whether the passed list is null or not.
If the is null and have no "if" check on the null value then the prog would crash at the "for" loop.
Ok, it works as shown before.
However I would appreciate to be able to treat an null value as an empty list.
I want to omit the leading, wrapping "if" check.
Is this possible somehow?
Maybe with a workaround like:
for (MyObject mo : mylist; (mylist = NOT(null)))
Robin