I want to write a java program to read in two integers and then
output a random integer number generated between these two integers.
Is there any tips? Is there a random Java API (libraries) that I could use?
Tks.

Recommended Answers

All 2 Replies

Yes, its called Random. You will find it in the API JavaDoc

Take a look at this :

import java.util.Random;
	static Integer randomNumber;
	static Random generator = new Random();

        //Returns a random Integer starting in the range of (startingPoint, (startingPoint + range) - 1)
	public static Integer createRandomNumber(Integer range, Integer startingPoint) {
		randomNumber = generator.nextInt(range) + startingPoint;
		return randomNumber;
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.