+ 1
Urgent help
Dear experts in Java Will someone offer me some basic tasks for the if statements please and thank you 🙏🏻
1 ответ
0
The condition for an if statement is boolean, meaning its either true or false. So you need to come up with a condition, such as if(x < y)
and if this is a true statement then the body will execute.
int x = 2;
int y = 3;
if(x < y)
System.out.print(x + “ is less then “ + y);
else
System.out.print(y + “ is less then “ + x);
Try this and play around with the numbers. Notice how it will always say the lesser number is less then the greater number, because if the way the if-else statement is constructed.