[Solved] I confused with the error when i wrote the code like short a = 1;a=a (short)1; [closed]

You can better try with: a= (short)1; instead of a=a (short)1; ClassCastException is:- Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. Although in your code it is not making sense how you receive the ClassCastException even after if we change as … Read more

[Solved] What is the difference between a double and short type in C? [closed]

From Wikipedia: Short: Short signed integer type. Capable of containing at least the [−32,767, +32,767] range;[3][4] thus, it is at least 16 bits in size. The negative value is −32767 (not −32768) due to the one’s-complement and sign-magnitude representations allowed by the standard, though the two’s-complement representation is much more common. Double: Real floating-point type, … Read more

[Solved] The shortest java code [closed]

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]