Prev Next

Java / Operators

Write a Java program to generate a random number between 0 to 99.

The below program uses the current time in milliseconds and apply modulo operator to pick a random number between 0 to 99.

public class RandomNumberGen {
	public static void main(String[] args) {
		long start_time = System.currentTimeMillis();

		System.out.println(start_time % 100);
	}
}

More Related questions...

Show more question and Answers...


Comments & Discussions