1. Member Join Date
Nov 2010
Posts
3
Rep Power
0

## printf

Heya, I'm doing an assignment and need to print an array in:

System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);
System.out.println(numbers + " " + numbers + " " + numbers + " " + numbers + " " + numbers);

this sort of format, but each value needs to be three digits long with leading zeros, I've found out that by using the formula (i.e. 3 goes to 003, or 10 to 010)
System.out.printf("%03d", numbers);
it will do that, but i cant seem to get more than one on each line, is this possible?

Note: numbers is the name of the array.  Reply With Quote

2. ## You just loop through it:

int count= 0;
for(count==0; count<=numbers.lenght; count++){
System.out.printf("%d, ", numbers[count]);
}  Reply With Quote

3. Member Join Date
Nov 2010
Posts
3
Rep Power
0

## I would do that but its got to be in a 5*10 grid. can you do that in a for loop?  Reply With Quote

4. ##  Originally Posted by razzle I would do that but its got to be in a 5*10 grid. can you do that in a for loop?
.........Yes  Reply With Quote

5. ## Just initialze a second count variable and everytime it is 5, move to the next line!  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•