Hint 3 on random numbers for Lab 2 (Fall 2024)

Here is program that will print a random integer between 0 and 10:
import java.io.*;
import java.util.*;
public class RandomDemo {
    public static void main(String[] args) {
        Random generator;
        int number;

        generator = new Random();
        number generator.nextInt(10);
        System.out.println(number);
    }
}


This topic: CenterForComputing > WebHome > Syllabi > SyllabiFall2024 > CSC121SylF2024 > CSC121F2024Lab02 > CSC121F2024Lab02Hint03
Topic revision: r1 - 2024-06-04 - CathyBareiss
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback