import java.util.Scanner;
public class BooleanProduct {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int n = 10;
int[][] A = new int[n][n];
int[][] B = new int[n][n];
//Fill A and B
int m,n2,p,q;
System.out.println("Enter number of rows for matrix A : ");
m = input.nextInt();
System.out.println("Enter number of columns for matrix A : ");
n2 = input.nextInt();
System.out.println("Enter number of rows for matrix B : ");
p = input.nextInt();
System.out.println("Enter number of columns for matrix B : ");
q = input.nextInt();
System.out.println("Enter elements for matrix A (by rows): ");
for (int i=0 ; i < m ; i++)
for(int j=0 ; j < n2 ; j++)
{
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < p ; i++)
for(int j=0 ; j < q ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
for(int i=0 ; i < m ; i++)
{
System.out.println();
for(int j=0 ; j < n2 ; j++)
{
System.out.print(A[i][j]+" ");
}
}
System.out.println();
System.out.println("Matrix B: ");
for (int i=0 ; i < p ; i++)
{ System.out.println();
for(int j=0 ; j < q ; j++){
System.out.print(B[i][j]+" ");
}
}
System.out.println();
}
int[][] C = booleanProduct(A,B, n);
{
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
System.out.print(C[i][j] + " ");
}
System.out.println("");
}
}
static int[][] booleanProduct(int[][] A, int[][] B, int n) {
int[][] C = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int[] tmp = new int[n];
for (int k = 0; k < n; k++) {
tmp[k] = product(A[i][k] , B[k][j]);
}
C[i][j] = sum(tmp);
}
}
return C;
}
static int product (int a, int b) {
return (a*b == 0) ? 0 : 1;
}
static int sum(int[] arr) {
for (int item : arr)
if (item == 1)
return 1;
return 0;
}
}
this is my error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at BooleanProduct.main(BooleanProduct.java:4)