bonsoir,

Voilà ma première participation au forum. Je suis encore débutant et voila
mon programme qui remplie un tableau de 2 dimensions et l'affiche. Mais apparemment, il y a un problème qui m'affiche le message
(non static method cannot be referenced from a static context)
C'est sur cette ligne que j'ai l'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
tableau[i][j]=sc.nextInt();
Mon deuxième but: j'ai le tableau suivant:
123
456
et je souhaite l'afficher comme ceci
14
25
36
Merci d'avance pour votre aide.

voila mon petit programme:
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
28
29
package javaapplication2;
 
import java.util.Scanner;
public class JavaApplication2 {
    Scanner sc=new Scanner(System.in);
 
    public static  void main(String[] args) {
        int [][] tableau=new int [2][3];
        remplir (tableau);   
        afficher (tableau);
 
    }
 
    static void  remplir(int [][] tableau){
        for (int i=0;i<tableau.length;i++){
            for (int j=0;j<3;j++){
                tableau[i][j]=sc.nextInt();
            }
        } 
    }
 
    static void afficher(int [][] tableau ){
        for (int i=0;i<=tableau.length;i++){
            for (int j=0;j<10;j++){
                System.out.println(tableau [i][j]+"\b");
            }
        }
    } 
 }