Why I am getting NZEC runtime exception in my Program?

Hii I am just starter in programming and I don’t know why it
throw NZEC run time exception. This question is from Medium level Andrew and the string`enter code
import java.util.Scanner;
class AMString
{
private static Scanner s;
public static void main(String arg[])
{
s = new Scanner(System.in);
int t = s.nextInt();
for(int k = 0; k < t; k++)
{
int m = s.nextInt();
int n = s.nextInt();
int q = 0,l = 0, count = 0;
String s1 = s.next();
String s2 = s.next();
int[][] c = new int[m][m];
while(++l < m)
{
q = q + (m - l)*(m - l);
}
int[] b = new int[q];
int p = 0;
for(int i = 0; i < m; i++)
{
for(int j = 0; j < m; j++)
{
int temp = 0, g = i, h = j;
if(s1.charAt(i) == s2.charAt(j))
{
while(g > 0 && h > 0)
{
temp = temp + c[g-1][h-1];
b[p] = temp;
p++;g–; h–;
}
c[i][j] = 0;
}
else
{
while(g > 0 && h > 0)
{
temp = temp + c[g-1][h-1];
b[p] = temp + 1;
p++; g–; h–;
}
c[i][j] = 1;
}
if(c[i][j] <= n)
{
count++;
}
}
}
for(int i = 0; i < q ; i++)
{
if(b[i] <= n)
{
count++;
}
}
System.out.println(count);
}
}
}

I don’t know JAVA but the following is acc. to C.
NZEC means Non-Zero Exit Code error.
Your Program should return 0 to indicate successful run.
Just write return 0; at the end.

Actually, Java doesn’t work like that. If he put return 0;, the program wouldn’t work because the main() method in Java can’t have a return value.

1 Like

Instead of private static void main
it should be private sub int main. Then it can return a value.