1 will be by default treated as an int in Java.
So, when you're doing ((short)1), the you're passing 1 as a short parameter through the function. The receiving argument should be of a short type.
Whereas, when you have short s =1, then it is obviously a short
integer.
Remember that in both the case, shorts will be converted to int(this is called type promotion) while performing operations. And, if operated with double operands, those int's will get promoted to double.
What's the difference between them, and which is better?
Both are doing the same operations finally(passing a short variable as an argument), and both of them are of equally better. But, you should prevent using short
integers, unless extremely required as it has some shortcomings(causes compile-time errors when you accidentally try to store an int/long to a short).