Prevent Negative numbers for Age without using client side validation.
- by Deepak
Hi People,
I have an issue in Core java.
Consider the Employee class having an attribute called age.
class Employee{
private int age;
public void setAge(int age);
}
My question is how do i restrict/prevent setAge(int age) method such that it accepts only positive numbers and it should not allow negative numbers,
Note: This has to be done without using client side validation.how do i achieve it using Java/server side Validation only.The validation for age attribute should be handled such that no exception is thrown