Let's say I have a class and I want one of its methods to behave differently depending on an argument. What I want to do is something like this (I know this doesn't work in Java):
class myClass(int a) {
public void myMethod() {
if (a == 1)
// do something
if (a == 2)
// do something else
}
}
Is there a way to do this?