-2
import java.util.Scanner;

class ScannerTest{

  public static void name(String[] args) {
    Scanner scan = new Scanner(System.in);
    short a[][] = {{1,2,3},{4,5,6},{7,8,9}};
    short b[][] = new short[3][3];
    System.out.println("Enter the matrix B:");
    for (int i=0; i<3; i++)
    {
        for (int j=0; j<3; j++)
        {
            b[i][j] = scan.nextShort();
            
        }
    }
    short c[][] = new short[3][3];
    int n = a.length;
    for (int i=0; i<3; i++)
    {
        System.out.println();
        for (int j=0; j<3; j++)
        {
            for (int k=0; k<3; k++)
            {
                c[i][j] +=(a[i][k]*b[k][j]);
            }
            System.out.print(c[i][j] + " ");
        }
    }

    
   }

}

When I compile and run the code it says that the main method is not found in the class ScannerTest, please define the method as public static void main(String[] args). I do not know how to fix this would much appreciate if someone could point out what's wrong.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Vivan
  • 1
  • 2
  • Does this answer your question? [What does "Could not find or load main class" mean?](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean) – Mark Rotteveel Jan 29 '22 at 07:54
  • Your class doesn't have a `main` method, it has a `name` method. A `main` method must be `public static void main(String[] args)`. – Mark Rotteveel Jan 29 '22 at 07:55
  • 1
    Apart from there being no `main` method in the code that you posted, I think that class `ScannerTest` needs to be public, as in: `public class ScannerTest`. – Abra Jan 29 '22 at 07:59

1 Answers1

0

main method represents the starting point of the program and you haven't defined the main method in the ur code snippet. These articles will help you to understand da workflow behind the main method. simple program of java java main method