SecureRandom random = new SecureRandom(); int max=50; int min =1; System.out.println(random.nextInt(max-min+1)+min);