开发者

Java program with two or more exceptions caused by similar values [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit t开发者_如何转开发he help center. Closed 10 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜