Some context: I'm parsing an accounting ledger which has account1
and account2
as int
types. Each is a number in the range [0, 99999]. I have many combinations to consider.
Ideally I'd like to use something like
switch (account1, account2){
case (1,1):
/*account1 is 1, account2 is 1*/
case (2,1):
/*account1 is 2, account2 is 1*/
}
and so on. (I only need to consider about 20 possible combinations).
Is there a way I can achieve this in Java?
I've considered this question Storing number pairs in java
and could build an IntPair
class. Perhaps if I define bool equals
then I could switch
on an instance, in a similar manner in which you can switch on java.lang.String
.