How does Java know/evaluate the comparison of two int
values;
for example:
int a=5;
int b=10;
How does it evaluates whethe
if (a > b) {
// a is bigger
} else if (a == b) {
// they are equal
} else {
// a is smaller.
}
EDIT: In answer to this follow up question:
How does it know that it is grater than if a >b retuns true
It depends what you mean by "it".
Java (the programming language) doesn't know anything. It is a language that has meaning ... not a thing capable of knowledge, in any sense.
Javac (the compiler) translates the Java code into a sequence of JVM bytecodes that mean the same thing as the program source code. Those byte codes say something like this:
Java (the command) interprets the bytecodes, or JIT compiles them to native code, and then executes the native code.
At the native code level, a sequence of instructions might do something like this:
The subtraction is performed at the hardware level using an ALU built from logic gates
And so on down to the level of the silicon.