title: Java cannot resolve method "size()"
body: <p>I'm not a regular java user, but I need to get the number of elements in a list in Java. I'm trying to use the size method, but it's not resolving as expected.</p>
  <p>List and Arraylist are imported into the file as expected.</p>
  <p>Code:</p>
  <pre><code>Optional&lt;List&lt;ColleagueDevice&gt;&gt; storeDevices = releaseService.storeDevices(storeNumber);
  int numberOfDevices = storeDevices.size();
  if (numberOfDevices == 5) {
      log.error(&quot;Failed to release device for colleague: {} in store {} as 5 devices are already released&quot;, body.getColleagueId(), storeNumber);
      return new ResponseEntity&lt;&gt;(
              //TODO: check ALREADY_HAS_DEVICE
              new UIStatus(HttpStatus.UNAUTHORIZED.value(), ALREADY_HAS_DEVICE),
              HttpStatus.UNAUTHORIZED
      );
  }
  </code></pre>