import typeUse.*; import java.util.*; class JC { public static Collection<@Nullable Object> getNullableStuff() { return Collections.emptyList(); } public static Collection<@NotNull Object> getNotNullStuff() { return Collections.emptyList(); } void usage() { for (@NotNull Object o : getNullableStuff()) { System.out.println(o.getClass()); } for (@Nullable Object o : getNotNullStuff()) { System.out.println(o.getClass()); } getNullableStuff().forEach((@NotNull Object s) -> System.out.println(s.hashCode())); getNotNullStuff().forEach((@Nullable Object s) -> System.out.println(s.hashCode())); } }