0
 out.append("Line " + (j+1) + ": "); System.out.print("Line " + (j+1) + ":"); for (int i = 0; i < lotto.length;i++){ lotto[i] = r.nextInt(45)+1; out.append(lotto[i] + " "); System.out.print(lotto[i] + " "); } 

Now it is printing as below

Line 1: 41 7 38 20 38 39 Line 2: 12 35 5 27 4 33 Line 3: 9 3 10 15 35 2

2
  • What is the question? Commented Apr 13, 2013 at 11:34
  • what output you are expecting ?? Commented Apr 13, 2013 at 11:42

1 Answer 1

1

Because you are printing the new line after printing Line n

You should use println after the inner for that prints the numbers.

Like

// print "Line n" System.out.print("Line " + (j+1) + ":"); for (int i = 0; i < lotto.length;i++){ lotto[i] = r.nextInt(45)+1; out.append(lotto[i] + " "); // Print in the same line the numbers System.out.print(lotto[i] + " "); } // Print the new line System.out.println(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.