Hello guys, Hope ur listening. I need my code to generate 6 random numbers for each line, instead of just 1. Furthermore, there should be no duplicate numbers on any particular line. So far I have gotten this code to print only a single number per line, so I need to add 5 more numbers to each line. Thanks in advance.import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Lottotest

private static List lottoBarrel = new ArrayList(45);

private static void initializeBarrel()
for (int i = 1; i < 45; i++)
lottoBarrel.add(new Integer(i));

private static void printBarrel(String message)
System.out.println(message + "\n");
for (int i = 1; i <= 6; i++)
System.out.println("number " + i +" = " + lottoBarrel.get(i));

public static void main(String[] args)
printBarrel("Barrel rolled:");

10 Years
Discussion Span
Last Post by jwenting

1) you're not generating any random numbers at all. You're drawing your numbers from a collection of fixed numbers which has been ordered using a random sequence. That's not the same thing (but it's likely you want in this case).
2) you're explicitly printing a line terminator after every number when you call println, which is why you see your non-random numbers each on a line of their own.
3) you're not using code tags.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.