I have an int array for which i have allocated space for 100 elements. There is another array inShort[]. How can I convert inInt[] to inShort[]?
Is it necessary to allocate new memory for inShort[] or there is a way through which I can cast to inInt[]?
int inInt[] = new int[100];
short inShort[];
However, you are very likely to overflow the short if the int is outside the range of the short (i.e. less than -32,768 or greater than 32,767). It’s actually really easy to overflow the short, since an int ranges from -2,147,483,648 to 2,147,483,647.