I'm an idiot, need simple help

Well I did aweosme in my first java course, but this second one is making me look like an idiot. My first assignment is to edit the following program so that it outputs 10 numbers per line. We can only edit the display part of the program. My usual firend I ask for help is MIA right now, so I was wondering if anyone could push me int he right direction.

I know I need to add a loop where it adds numbers to arrays if there is a number to add, I just forget how to do it.

import java.io.*;

import java.util.*;

class APISortMain {

public static void display(int[] a, int size){

for(int i=0; i<size; i++){

System.out.print(a+"\t");

}

System.out.println();

System.out.println();

}

public static void main(String args[]) throws IOException {

Random r = new Random();

//Arrays A = new Arrays();

int[] able = new int[500];

int amount = 50+r.nextInt(30);

for(int i=0; i><amount; i++){

able = 1000+r.nextInt(5000);

}

System.out.println("Data unordered");

display(able, amount);

System.out.println("Data ordered");

Arrays.sort(able, 0, amount);

display(able, amount);

amount = 50+r.nextInt(30);

for(int i=0; i><amount; i++){

able = 1000+r.nextInt(5000);

}

System.out.println("Data unordered");

display(able, amount);

System.out.println("Data ordered");

Arrays.sort(able, 0, amount);

display(able, amount);

}

}

I'm no asking you to do it for me, just give me a little help, please!>

[1658 byte] By [KPheaseya] at [2007-11-26 17:07:49]
# 1
Please you code tags.Are you asking how to add a loop? http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html
zadoka at 2007-7-8 23:35:39 > top of Java-index,Java Essentials,Java Programming...
# 2

> public static void display(int[] a, int

> size){

> for(int i=0; i<size; i++){

>System.out.print(a+"\t");

>}

>System.out.println();

>System.out.println();

> }

You need to create Strings of 10 numbers and display them. If the size of a is 25 then you need to create a String of

a[0] through a[9]

a[10] through a[19]

and a[20] through a[24]

the loop has two part

// count what goes into the string

int count = 0;

// String to output, start empty

String writeThis = "";

// look at each element in a

for( int i=0, i< a.size(), i++) {

// put 10 in a string

writeThis += a + " ";

count++;

if (count = 10) {

// now you have 10 numbers in writeThis --

// clean up

writeThis = "";

count = 0;

}

} // end loop

// check to see if any numbers left to output

if (writeThis.length > 0 )

// you've got the remaining ones to deal with

}

BillBlalocka at 2007-7-8 23:35:39 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks Bill, I got it.
KPheaseya at 2007-7-8 23:35:39 > top of Java-index,Java Essentials,Java Programming...