I have the following code to generate an array of random numbers. How can I get it to print the array like [5,89,76,34,2] instead of printing down. I don't think it is actually printing the array just the numbers.
import java.util.Random;
public class RandomIntArray
{
private int[] numbers;
public RandomIntArray(int size)
{
numbers = new int[5];
}
public static void main(String[] args)
{
int[] numbers = new int[5];
Random generator = new Random();
for (int i = 0; i < numbers.length; i++)
{
int n = generator.nextInt(100);
numbers[i] = n;
}
for (int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i]);
}
}
}