hey guys i have a question about implimenting a random number method. i cant remember what i have to import for it. also i dont remember how to set the range. any help is much appreciated
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
hey guys i have a question about implimenting a random number method. i cant remember what i have to import for it. also i dont remember how to set the range. any help is much appreciated
Hello big_c,
You need to import java.util.*;
You can generate a random number like this:
This code will print a random number between 0 - 100import java.util.*; public class RandomNumber { public static void main(String[] args) { Random random = new Random(); int rand = random.nextInt(100); System.out.println(rand); } }
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.
sweet deal. i really wish i didnt lose my book lol