Let's go for real hacky:
Code:
import java.util.function.IntConsumer;
public class Test {
private static final int HIGH_VALUE = 10;
public static void main(String... args) {
int input = 9;
operate(input);
}
private static void operate(int input) {
IntConsumer lowInput = (int i) -> System.out.println("The low number is: " + i);
IntConsumer highInput = (int i) -> System.out.println("The high number is: " + i);
IntConsumer[] consumers = {lowInput, highInput};
consumers[(~(input - HIGH_VALUE) & 0x80000000) >>> 31].accept(input);
}
}
Just for fun, I reimplemented this in x86
Code:
HIGH_VALUE equ 10
global _main
extern _printf
section .text
_main:
mov eax,3 ; Input value
mov edi,eax
sub eax,HIGH_VALUE
neg eax
and eax,0x80000000
shr eax,31
mov ecx,[jmp_table+eax*4]
push edi
jmp ecx
retn
is_low:
push low
jmp operate
is_high:
push high
operate:
push message
call _printf
add esp,12
retn
jmp_table:
dd is_low
dd is_high
low:
db 'low', 0
high:
db 'high', 0
message:
db 'The %s input is %d.', 10, 0