lundi 10 octobre 2016

Java - || and && in the if statement

I'm trying to do some validation for a user entered date. Is there a way to have multiple || statements and then an encompassing && statement for them all? Here's my code:

if (month == 4 || month == 6 || month == 9 || month == 11 && day < 31 && day > 0)

As of right now the && statements only apply to the month == 11 variable. Is there an easy fix to using && in this if statement (without having to copy/paste it after every variable)?

Aucun commentaire:

Enregistrer un commentaire