int randomNumber = ( int )( Math.random() * 9999 );
if( randomNumber <= 1000 ) {
randomNumber = randomNumber + 1000;
Math.random() is a method that generates a random number through a formula. It returns a double however, so casting is required if you want an integer, float, or etc. The if block makes sure that the number is above 1000 and is a 4-digit number.
7
solved random function in Java [closed]