Whenever I use byte or short data type as a method parameter, on method calls, I am required to explicitly cast the values I pass to those methods.
To better explain:
void foo(short x)
{}
void main() {foo((short)32);}
If I dont use short here then warning is generated.
method foo in class px cannot be applied to given types
required: byte
found: int
How can I get it better?
No way out.
Java doesn't have a way to code byte or short literals. Any number literal is an int value and converting an int to a short without casting always creates a warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With