Why did guava/java use possible.isPresent() as opposed to Optional.isPresent(possible)?
问题 On https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained it is explained that guava (and later java 8) adds a generic class Optional in order to clear up null checking. If a function returns an Optional it requires the caller to unwrap the string before using it. this is normally done in the form Optional<String> possible = returnAnAbsentOptional(); if(possible.isPresent()){ System.out.println(possible.get()) } If returnAnAbsentOptional returns null, we have a NPE all