In java is there a faster way of doing this?
if (keyCode != 66 && keyCode != 8 && keyCode != 21 && keyCode != 22) {
}
keyCode is an int.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
findkeyCodein it. If you found it, then your condition is false. Otherwise it’s true.As per Dave’s comment: