I have a method that takes an int [] parameter. I want to give him a lot of shorts. But all I get is "incompatible types: short [] cannot be converted to int []". Why is this? example:
short[] arr = new short[2]; arr[0] = 8; arr[1]=9; example(arr); example(int[] anArray){ }
As far as I know, the abbreviation from int is just expanding, so it should be automatically entered, right? How to convey it then? Thank.
, short[] int[]. , short int, Java , short int. .
short[]
int[]
short
int
Java-API , Arrays.sort, .
Arrays.sort
short[], int[], , example(short[] anArray).
example(short[] anArray)
JLS, 5.1, , , , 5.1.12, " ":
> Any conversion that is not explicitly allowed is forbidden.
, .
Java , short ints, .
, IS-not-A int.
int , , , :
short x = 4; int y = x;
.
22 :short to byte charcharint , charlong to byte, short, char intfloat to byte, short, char, int longdouble to byte, short, char, int, long float, .double float IEEE 754 (Β§4.2.4). , , . NaN float NaN, .T , n , n - , . , .a char T , n , n - , . , , 16- .
22 :
short to byte char
char
int , char
long to byte, short, char int
float to byte, short, char, int long
double to byte, short, char, int, long float
double float IEEE 754 (Β§4.2.4). , , . NaN float NaN, .
T , n , n - , . , .
a char T , n , n - , . , , 16- .
for more information: http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.3
Source: https://habr.com/ru/post/1530481/More articles:Parallel cleaning in .NET. - c #OpenGL32.lib not binding properly - c ++problem with virtual function design - c ++SoapUI - How to use property passing with a POST request - jsonAlign the div to the bottom without removing it from the stream - htmlPyDev does not appear in Eclipse despite Java 7 - pythonprepareStatement does not work with sqlite - javaStrange (unicode?) Characters - unicodeCreating a patch using the P4Eclipse plugin fails with "Invalid or Unset Perforce Password (P4PASSWD) - eclipseΡΡΠΎ ΠΎΠ·Π½Π°ΡΠ°Π΅Ρ npm install -d --save - node.jsAll Articles