Java Optional - If Else Statements
<p>So after some reading I've seen that </p>

<pre><code>if (optional.isPresent()) {
    //do smth
}
</code></pre>

<p>is not the preferred way to use Optional (<a href="http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html" rel="noreferrer">http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html</a>). But if I have an if-statement like this:</p>

<pre><code>if (optional.isPresent()) {
    car = getCar(optional.get());
} else {
    car = new Car();
    car.setName(carName);
}
</code></pre>

<p>Is this the best way to do this or is there a more recommended way?</p>