Do use assertions to validate arguments to a private method.

Do use assertions to validate arguments to a private method.

If we write a private method , we almost certainly wrote any code that calls it,when we assume that the logic in code calling our private method is correct.

private void doMore(int x) {
assert (x > 0);
// do things with x
}

The only method in the program diff that matters between the preceding example and the one before it is the access modifier.

By:UMANG
Date:2002-03-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related scjp1.5 chap4 Links

scjp1.5 chap4 interview questions and answers for experienced and fresher