Sunday, September 28, 2014

How to Disable Random Numbers in Java

Instructions

    1

    Open your Java programming editor and open the Java app project you want to edit. Open the source code file you want to use to create the random number.

    2

    Initialize the random generator class. Initialization lets you set up the generator to return a number. Add the following code to the file:

    Random random = new Random();

    3

    Generate a number. You specify the range in which you want to generate a number. The range is from zero to a positive integer number. For instance, the following code generates a number between zero and five:

    int number = random.nextInt(5);

    4

    Pass the integer to the function that disables the control. For instance, the following code passes the random number to the "DisableControl" function:

    DisableControl(5);



No comments:

Post a Comment