I am programming a java class, where the given parameters could be invalid, but still be the right type. I want my class to take two integers, but the second one is not allowed to be zero. What do I have for possibilities to interrupt the Constructor, maybe returning manually null? What are my possibilities?
public class Test {
private a, b;
public Test(p1, p2) {
if (p2 == 0) return null;
a = p1;
b = p2;
}
}