+ 3
whan can do write a operator same "or", but just any of two operant must be true ?
whan can do write a operator same "or", but just any of two operant must be true ?
2 ответов
+ 4
int x = 15;
int y = 17;
if(x > 16 || y > 17){
System.out.println("welcome"); // this code will be executed
}else{
System.out.println("you are too young ");
}
0
|| is the or operator
example:
int currentYear = 2016;
if (currentYear == 2016 || currentYear == 2017) {
// it is either 2016 or 2017
}