Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.security.GeneralSecurityException; public class Main { /** * @throws GeneralSecurityException if {@code candidate} is negative * or larger than {@code maxExpected}. */ public static void validateVersion(int candidate, int maxExpected) throws GeneralSecurityException { if (candidate < 0 || candidate > maxExpected) { throw new GeneralSecurityException( String.format("key has version %d; only keys with version in range [0..%d] are supported", candidate, maxExpected)); } } }