Generating random numbers in Java

Q1. Can you write Java code to generate random numbers between a given range? A1. E.g. 0 and 9 or 5 to 35, and so on.

The “nextInt()” method works from “0” onwards. So, “rand.nextInt(9)” will return 9 numbers…

This content is for 100-Day-Full-Access, 200-Day-Full-Access, 365-Day-Full-Access, and 2-Year-Full-Access members only.

Register

50+ Free Java FAQs

50+ Free Big Data FAQs

Already a member? Log in here

300+ Java Interview FAQs

Tutorials on Java & Big Data