// Use the java.util.Random class Random rand = new Random(); int n = 10 + rand.nextInt(90); // or, use the Math class method int m = (int)(10 + 90*Math.random());