Sum of Even Elements in Matrix

Given a 3×3 matrix the task is to calculate the sum of even elements in matrix.

Example: Consider the 3×3 matrix

418
379
216

Sum of all elements = 20

Java
import java.util.*;
class SumMatrixEE
{
    public static void main(String args[])
    {
        int sum=0;
        Scanner sc=new Scanner(System.in);
        int ar[][]=new int[3][3];
        System.out.println("Enter matrix elements:-");
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                ar[i][j]=sc.nextInt();
            }
        }
        for(int i=0;i<3;i++)
        {
            for(int j=0;j<3;j++)
            {
                if(ar[i][j]%2==0)
                {
                    sum=sum+ar[i][j];
                }
            }
        }
        System.out.println("Sum of even elements in matrix: "+sum);
    }
}
Java