In java is there a faster way of doing this?
if (keyCode != 66 && keyCode != 8 && keyCode != 21 && keyCode != 22) {
}
keyCode is an int.
Faster? Is it too slow for you? Don't play optimizer. Write readable code and leave microoptimizations to the optimizer. Premature optimization is the root of all evil
Edit after josh's comment:
If you have really many of them, put them in a container (such as a set or an array) and find keyCode in it. If you found it, then your condition is false. Otherwise it's true.
As per Dave's comment:
if(!MyCodesSet.Contains(keyCode)){
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With