Creating new List of objects in Java throws a NullPointerException
<p>I have short question because I can't understand my mistake.</p>

<p>I have a collections:</p>

<pre><code>      List&lt;ManagedFilesAuthorityDTO&gt; managedFilesAuthorityDTOs = filesAuthorityRepository.findAll().stream()
        .map(ManagedFilesAuthorityDTO::new)
        .collect(Collectors.toList());
</code></pre>

<p>then I'm creating new list </p>

<pre><code>List&lt;ManagedFilesAuthorityDTO&gt; outputFileList = null;
</code></pre>

<p>and I would like to iterate for <em>managedFilesAuthorityDTOs</em> and assign some object to <em>outputFileList</em>.</p>

<p>Here's my loop:</p>

<pre><code> for (ManagedFilesAuthorityDTO dto : managedFilesAuthorityDTOs) {
        outputFileList.add(dto);
    }
</code></pre>

<p>And I still getting <strong>NullPointerException</strong> because my outputFileList is equals null. What I am doing wrong that I can't create new List?</p>