This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hello, I have to make some applets for school with a dice. If the comuter makes me a number with math.random I want to show a picture of a dice with that number of dots on it. but I don't know how to work with a Switch statement. and where I have to put them in my applet?( under the init() stuff or where else?) So I would appreciate it if you would help me. Thijs Haitjema email@example.com
Hi, Welcome to JavaRanch! Sun's online Java Tutorial has a section on applets which would help you understand how applets are put together, and what the "init" and "start" methods are for. As far as random numbers goes, to get a random number from 0 to 5, inclusive (six different possibilities), you could use the java.util.Random class:
You could then use this number as an index into an array of Image objects.