Almost correct:
System.out.println((int)Math.signum(input.nextInt() - input.nextInt());
“Almost” due to possible integer overlow. Also your longer code might actually be faster (signum()
operaton on floating-point numbers), not to mention more readable.
1
solved The shortest java code [closed]