Wouldn't you have to do a check using an if statement to see if one number was bigger than the other? Then print out the message to console if 10 is more than 9 of something like "ten is bigger than nine"..
Also you need to put your code in tags - makes it easier to view
There are circuits in the chip which evaluate that inequality. I think they work by subtracting the two numbers and then looking for negative flags or zero flags, but I am not certain. The + operator is overloaded to operate on Strings. If you have a String and something else (in fact anything can be used), the + operator converts that something else to a String and joins the two Strings together. In the case of a boolean it turns into “false” or “true”.
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.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
posted 4 years ago
Thank you so much for all your wonderful explenations.. Now it's very clear to me...