Comment stocker des entiers dans un tableau ?
salut a tous g veux lire les entiers dans un tableaux voici mon code:
Code:
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
| import java.io.*;
import javax.swing.table.*;
import java.util.Scanner;
public class kam {
public static void afficherTabl(int[] tb){
tb= new int[4];
for (int i= 0; i < tb.length; i++)
{
//System.out.print("La case " +(i+1)+ " contient "+tb[i]);
System.out.println(tb[i]);
}
}
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
int [] tab1;
tab1 = new int[4];
//Remplissage du tableau//
for(int j =0; j<tab1.length ; j++)
{
System.out.println("Entrer la valeaur de la case "+(j+1));
tab1[j]= System.in.read();
}
afficherTabl(tab1);
}
} |
Malheuresement mon code ne marche pas
g veux savoir comment stocker des entiers dans un tableaux?