[Tableau] Créer une fonction qui retourne un tableau
Bonjour,
J'aimerais créer une bête fonction qui retournerait un tableau. Voici comment je procède.
Code:
1 2 3 4 5 6 7 8
|
public static int[] tableau (int taille) {
int[] tab = new int[taille];
for (int i = 0; i < tab.length; ++i) {
tab[i] = i + 2;
}
} |
Et voici mon main :
Code:
1 2 3 4 5 6
|
public static void main(String[] args) {
System.out.print("Taille du tableau : ");
int N = Clavier.lireInt();
tableau(N);
} |
Pourtant, à l'exécution, la console affiche le nombre N.
Comment faire pour afficher le tableau ?
Merci !