void (boolean b) { System.out.println(Optional.of("xyz").get()); Optional<String> test; if(b) { test = Optional.of("x"); } else { test = Optional.of("y"); } System.out.println(test.get()); if(b) { test = Optional.of("x"); } else { test = Optional.empty(); } System.out.println(test.<warning descr="'Optional.get()' without 'isPresent()' check">get</warning>()); }