I wonder if there is a more elegant way to write an if statement with a lot of || in java. I've given different values to alphabet letters:
A,O,I,B,T,S,M,N -> 1
C,D,F,G -> 5
W,Y,Z,H,Q -> 10
So, I want to check a given letter and if is equal with one of the 2nd group for example to get 5. Right now I'm checking like this:
String value;
if (getLetter().equals("Α")|| getLetter().equals("O") ||
getLetter().equals("I") || getLetter().equals("B") ||
getLetter().equals("T") || getLetter().equals("S") ||
getLetter().equals("N") || getLetter().equals("N"))
value = "1";
is there a better way to do it?
Aucun commentaire:
Enregistrer un commentaire