bonjour j'ai écrit un programme qui charger un tableau avec un nombre aléatoire entre 0 et 5
et qui affiche le contenu
sauf que le contenu reste toujours égal a zero

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.math.*; 
public class projet1tableau {
    public static void charger(int [] tab)
    {
    	tab=new int[20];
    	for (int i=0;i<20;i++)
    	{
    		tab[i]=(int)(Math.random() * (5 - 1)) + 1;
    	}
    }
 
    public static void affichage (int [] tab)
    {
    	for (int i=0;i<20;i++)
    	{
    		System.out.println(tab[i]);
    	} 
    }
 
    public static void main(String[] args) {
 
    int [] tableau=new int [20];
    charger (tableau);
    affichage(tableau);
    	System.out.println("Hello World!");
    }
}