Virusbeatbox
Gebruiker
- Lid geworden
- 18 dec 2007
- Berichten
- 201
Beste, ik zit met volgend probleem. Ik moet een 2 dimensionale array creëren met daarin een random tussen 7 en 77 en deze afdrukken op het scherm. Ik heb reeds dit maar krijg steeds een foutmelding... kan iemand mij helpen?
import java.util.Random;
public class oefening5
{
public static void main(String[] args)
{
int[][]array = new int[3][];
array[0] = new int [3];
array[1] = new int [2];
array[2] = new int [1];
System.out.println("Waarden");
outputArray(array);
}
public static void outputArray(int[][] array)
{
Random randomNumbers = new Random();
int getal = 7 + randomNumbers.nextInt(77);
for (int row = 0; row < array.length; row ++)
{
for (int column = 0; column < array[row].length;column++)
System.out.print(array[row][column]+getal);
System.out.println();
}
}
}
import java.util.Random;
public class oefening5
{
public static void main(String[] args)
{
int[][]array = new int[3][];
array[0] = new int [3];
array[1] = new int [2];
array[2] = new int [1];
System.out.println("Waarden");
outputArray(array);
}
public static void outputArray(int[][] array)
{
Random randomNumbers = new Random();
int getal = 7 + randomNumbers.nextInt(77);
for (int row = 0; row < array.length; row ++)
{
for (int column = 0; column < array[row].length;column++)
System.out.print(array[row][column]+getal);
System.out.println();
}
}
}
Laatst bewerkt: