Pages

Wednesday, April 08, 2015

Write a program that print static Random Number

Input:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import java.util.Random;

public class StaticRandomNo {

    public static void main(String[] args) {
            // always produced same nomber
        Random rand = new Random(20071969);
            for (int j = 0; j < 10; j++) {
                int pick = rand.nextInt(10);
                System.out.print(pick+ "   ");
            }
            System.out.println();
        }
    }

Output / Run:

3   0   3   0   7   9   8   2   2   5   
BUILD SUCCESSFUL (total time: 1 second)

No comments:

Post a Comment