@@ -0,0 +1,829 @@
+%0Aimport com.google.common.base.Optional;%0A%0A%0A/**%0A* how to use optional?%0A* the guava cache not allowed return null value. optional make guava perfect.%0A* if object null then just return absent value.%0A* that a great idea. best work guava!! %0A**/%0Aimport com.google.common.base.Optional;%0A%0Apublic class guavaOptionalDemo %7B%0A%0A%09public static Optional optionalStringVal()%7B%0A%09%09return Optional.of(%22test%22);%0A%09%7D%0A%09%0A%09public static Optional optionalObjVal()%7B%0A%09%09test t = new test();t.name=%22hello guava%22;%0A%09%09return Optional.of(t);%0A%09%7D%0A%09%0A%09public static Optional optionalNull()%7B%0A%09%09return Optional.absent();%0A%09%7D%0A%09%0A%09%0A%09%0A%09public static void main(String%5B%5Dargs)%7B%0A%09%09System.out.println(optionalStringVal().orNull());%0A%09%09System.out.println(((test)optionalObjVal().orNull()).name);%0A%09%09System.out.println(optionalNull().orNull());%0A%09%7D%0A%7D%0A%0Aclass test%7B%0A%09public String name;%0A%7D

add guava optional use demo