title: Merge single objects and list of objects into a single list of objects in Java
body: <p>Given a list of objects</p>
  
  <pre><code>// ["A", ["B", null, "C"], "D", ["E"], [], null, "F"];
  List&lt;Object&gt; objects = Arrays.asList("A", Arrays.asList("B", null, "C"), "D", Arrays.asList("E"), Arrays.asList(), null, "F");
  </code></pre>
  
  <p>Is there a simple way to combine the non-null values into a single list <code>["A", "B", "C", "D", "E", "F"]</code>?</p>
  
  <p>Some of you insist the post has to show what was tried</p>
  
  <pre><code>objects.stream().map(o -&gt; {
          if (o instanceof List) {
              return ((List) o).stream();
          } else return objects.stream();
      }).filter(Objects::nonNull).collect(Collectors.toList()));
  </code></pre>
  
  <p>obviously the above didn't work.</p>