//for Java 10 boolean result = true; var objResult = new Object() { boolean success = result; }; System.out.println(objResult.success);