import javax.annotation.Nonnegative; import java.util.Random; public class LongRangeAnnotation { @Nonnegative int method() { return new Random().nextInt(100); } @Nonnegative int x; @Nonnegative double y; void testField() { if(x < 0) { System.out.println("Impossible"); } if(y < 0) { System.out.println("Doubles are not supported yet"); } } void testAnnotated() { int value = method(); if(value == 0) { System.out.println("Zero"); } else if(value > 0) { System.out.println("Positive"); } } }