product between 2 arrays of 2 dimensions and be the score is stored in another array using ecplise and gridsim
for exemple:
mat3[i][j]= mat1[i][j]* mat2[i][j]

for(int r=0;r<numRows;r++)
    for(int c=0;c<numCols;c++)
        mat3[r][c]= mat1[r][c]* mat2[r][c];

Thanks a lot i have resolve it here my code if any one want it

package projet1;



//Ceci importe la classe Scanner du package java.util
//import java.util.Scanner; 
//Ceci importe toutes les classes du package java.util
import java.util.*;


public class sdz1 { 

 public static void main(String[] args) {
        // TODO Auto-generated method stub

        //    System.out.println("Vous avez saisi le caractère : " + str);
         //   System.out.println("FIN ! ");
    Scanner sc = new Scanner(System.in);        
    final int N = 20;
    //int const n=20;
    int i,j,k,l1,l2,c1,c2;
        i=j=k=l1=l2=c1=c2=0;
    int Mat1[][] = new int[N][N];
    int Mat2[][] = new int[N][N];
    int Mat3[][] = new int[N][N];

    do
      {
        System.out.println("Donner le nombre de lignes de la matrice n° 1");
        l1=valide(l1);
        System.out.println("Donner le nombre de colonnes de la matrice n°1");
        c1=valide(c1);
        System.out.println("Donner le nombre de lignes de la matrice n° 2");
        l2=valide(l2);
        System.out.println("Donner le nombre de colonnes de la matrice n°2 ");
        c2=valide(c2);

        if (c1 != l2) System.out.println("Les tailles des deux matrices sont incompatibles !");
      } while(c1!=l2); 

       System.out.println("Tailles des matrices est bien choisis Votre nouvelle matrice aura cet taille "+l1+" lignes et "+c2+" colonnes");
       for(i=0; i<l1; i++)
                        {
                         for( j=0; j<c1; j++)
                                          {
                                            System.out.println("Donner l'element d'emplacement ["+(i+1)+","+(j+1)+"] de la premiere matrice");
                                            Mat1[i][j] = sc.nextInt();
                                          }
                        }
       for(i=0; i<l2; i++)
                        {
                         for(j=0; j<c2; j++)
                                          {
                                            System.out.println("Donner l'element d'emplacement ["+(i+1)+","+(j+1)+"] de la dexieme matrice");
                                            Mat2[i][j] = sc.nextInt(); 
                                          }
                        }

       for(i=0; i<l1; i++)
                        {
                         for(j=0; j<c2; j++)
                                          {
                                            Mat3[i][j]=0;
                                            for(k=0; k<c1; k++)
                                                             {
                                                               Mat3[i][j]= Mat3[i][j] + Mat1[i][k] * Mat2[k][j];
                                                             }
                                           }
                        }

      System.out.println("le produit de la première et la deuxième matrice donne :");
      for(i=0; i<l1; i++)
                       {
                        System.out.print("(");
                        for(j=0; j<c2; j++)
                                         {
                                          System.out.print(Mat3[i][j]+"\t");
                                         }
                        System.out.println(")");
                       }

              } // accolade void main

// Méthode pour limiter le nbr de lignes & le nbr de colonnes entre [0 20]          
   public static int valide(int x)
       {
         do
           {
             Scanner sc = new Scanner(System.in);
             x = sc.nextInt(); 
             if ((x<0)||(x>20))
             System.out.print("vous devez entrer une valeur entre 1 et 20 : ");
           }
         while((x<=0)||(x>20));
         return (x);
       }


} // accolade classe sdz1

It work perfectly but now i want to use random to enter aleatory numbers and i don't know how and where i must put it

In your current code you populate the array with sc.nextInt(), now you want to populate them with random numbers. There is a method called Math.Random() which gives you a random number from 0 to 1 (including 0, not including 1).
You will have to 'stretch' the number you get to the right width (1-20) like so:

MatX[i][j]=(int)(Math.Random()*<Max-Min Here!>)+<Min Here!>;

just add a few lines in your previous code

/* create a random generator with a seed */
Random randomGenerator=new Random(System.currentMillis());

for(int r=0;r<numRows;r++) {
    for(int c=0;c<numCols;c++) {
        mat1[r][c]=randomGenerator.nextInt();
        mat2[r][c]=randomGenerator.nextInt();

        mat3[r][c]= mat1[r][c]* mat2[r][c];
    }
}

are you trying to do is matrix multiplication?? then the loop will be different

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.