jeudi 14 juin 2018

Is it possible to give a single variable multiple integer values to be checked for in an 'if statement'

So I'm doing code for school, and am confused on how I receive an "Illegal start of expression ... not a statement" error from Netbeans. I'm coding in Java and am still quite new to it.

Long story short, I want to know if there's a way to make a single variable be checked for multiple integer values (not sure if I worded that correctly.) Here is my code, the error it returns was mentioned in first paragraph:

 if (month == 1) && (month == 3) && (month == 5) && (month == 7) && (month == 8) && (month == 10) && (month == 12)

It's my first time using the sight so I apologize if the format wasn't correct. Thanks

Aucun commentaire:

Enregistrer un commentaire