COMP 248 Lecture 1: ExampleRandomGenerator.java

55 views1 pages

Document Summary

/* comp 248: example on how to use the random class */ // import this class to be able to use the random class import java. util. random; public class examplerandomgenerator { public static void main(string[] args) { // create an object of the class random. // let the generator generate a random integer bewtween 0 (inclusive) and 4 (exclusive) // for more information on the random class and the various methods available, see https://docs. oracle. com/javase/8/docs/api/java/util/random. html int randomintbetween0_1_2_or_3 = mygenerator. nextint(4); System. out. println("here is a random integer between 0 (included) and 4 (not included): " + randomintbetween0_1_2_or_3); System. out. println("\njust for fun, here are 10 more"); for (int i=1; i<10; i++) {

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions