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 you're looking for how to compare values in code, Stephen C's answer shows how to do just that.
If you're interested of how the actual machine does the comparison, there's certainly a lot of variety just like djna suggests.
Here's one way the computer may do the comparison when the Java's correct bytecode as described by Tim is invoked:
Lets think in binary;
5 = 0000 0101
10 = 0000 1010
(Note: I left out some zeros just to keep this simple)
Since in binary the values are multiples of 2 combined starting from right, it's easy to do a bit comparison;
Certainly this checking can be done in a bit more fuzzy and definately more complex but better performing way but that's the way it works on the basic machine level.