accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Medinets <david.medin...@gmail.com>
Subject Re: Non Short Circuit Logic
Date Wed, 12 Sep 2012 20:54:41 GMT
I didn't know for sure how the for loop acts when a null is the list.
So I wrote some code:

  List<String> strings = new ArrayList<String>();
  strings.add("a");
  strings.add(null);
  strings.add("b");
  for (String s : strings) {
    System.out.println(s);
  }

The result is:

a
null
b

Therefore, testing for null within a for loop seems like a good idea.

Mime
View raw message