Shivv Krishna wrote:My question is: how this program will come to know that 10>9 true or false.. how bolean data type used in this program.
It ('
(10 > 9)') is called an "expression", and Java is full of them.
Some of them, eg '
10 > 9', are logical, "10 is greater than 9", so they return either true (if 10 is greater than 9) or false (if 10 is
not greater than 9) , which Java returns as a
boolean.
In this case, the expression can't return anything but true, since we know that 10
is > 9, but the things on either side of the '>' (called 'operands') don't have to be actual numbers, they can be variables
containing numbers, so you can just as easily write:
int x = 10;
if (x > 9) ...
but x could just as easily be 3 or 60, or -37, so it may not be so obvious. Regardless, it will always return the result of "x is greater than 9".
Others, eg '
10 * 9', are numeric, "10 times 9", so they return a number, in this case 90. And the same rules apply, the operands don't have to be actual numbers, they can be variables, eg '
x * y'.
There's a lot to know about expressions, so I suggest you read the
tutorials carefully.
HIH
Winston