Java program with two or more exceptions caused by similar values [closed]
I am working on project where I am trying to find programs which give any exception but because of close values. Let me explain by an example. I will highly appreciate any help and support. In the following program first fault is generated when x == 100 and second when x == 98. Cheers.
public class Fault {
public void faulty(int x, int y) {
int z;
y = 20;
int a [] = new int[10];
if (x == 100)
{
a[11] = 22;
}
if ( x == 98)
z= ( x + y )/0;
}
}
The second is obvious:
if ( x == 98)
z= ( x + y )/0;
Only Jon Skeet can divide by zero.
精彩评论