0
Why it happens like that?
Why it outputs second command though the numbers are the same? public class Program { public static void main(String[] args) { int a =6; int b =6; if (a<b) System.out.println("A is less than B"); else System.out.println("B is less than A"); The output is: B is less than A } }
3 Respostas
+ 1
Thank you codemonkey
+ 1
Thanks Tibor Santa. I understand it.
0
You are not checking for equality. You can modify your conditions like this:
if (a==b)
System.out.println("A is equal to B");
else if (a<b)
System.out.println("A is less than B");
else
System.out.println("B is less than A");